Db Transactions In Drupal 7
From the 7th release, Drupal provides a chance to assert Transactions covering those databanks that do not assert them. Nevertheless when you try to carry out 2 transactions simultaneously it may make more complex the process of their carrying-out. In that case their conduct will count on the sort of database used.
The same problem happens with inserting in C/C++. When your code has locked the box "A" and tries to block it once again, you will be confounded. And when you write a code which investigates whether there is any locking and makes the 2th try only under this circumstances of its lack, then such misunderstandings may be escaped. However this can run to previous blocking removal at the same time as you may still want it.
Java resolved the implanting problem with blocking in another way. Supporting embedded constructions Java permits you to mark a function as synchronized, that makes the last-mentioned await till the blocking is available, or delete the lock if it is no longer necessary. Read more in details full text about transactions in Drupal 7 in Internetdevels blog. Though it isn't possible to put down "transaction" function in PHP, one may adopt the Java embedded logic utilizing things with destructors and constructors. For this aim drupal created a wrapper group for designing and managing transactions in data bases - class DatabaseTransaction. It's utilized in the operation "$txn = db_transaction();" as the 1th action to do Transaction from the actual function, in which it's evoked. To begin a new transaction it is required to put down $ txn = db_transaction; in the code. The Transaction will stay open for a while the changeable $ txn is performed. If the variable $txn is got out, the Transaction will be executed. When the Transaction is inserted into different one, then Drupal will fulfill every manipulation apartly and an external transaction will be ended only if all the objects, that is all askings, are concluded with success.
When one of the appeals in a transaction goes wrong, a "rollback" (an acts which comes back the information to its first state since the transaction starts) of all modifications happens. If it is needed to finish one of the transactions prematurely, one has to remove the variable $ transaction utilizing the function unset. This blog tells about transactions and how Drupal can sustain them.