You are here

public function Transaction::__destruct in Transaction 6

Same name and namespace in other branches
  1. 5 transaction.module \Transaction::__destruct()

Complete the transaction by either performing a commit or a rollback depending on the state of the object's allow_commit property.

File

./transaction.module, line 34
Provides a database transaction system for use with InnoDB tables in MySQL.

Class

Transaction
Provides a nestable transaction system for handling commits and rollbacks.

Code

public function __destruct() {
  self::$Layers--;
  if (self::$Layers == 0) {
    if (self::$AllowCommit) {
      db_query('COMMIT');
    }
    else {
      db_query('ROLLBACK');
    }

    // Reset the ROLLBACK propagator
    self::$AllowCommit = TRUE;
  }
}