You are here

public function DatabaseTransaction_sqlsrv::__destruct in Drupal driver for SQL Server and SQL Azure 7.2

Same name and namespace in other branches
  1. 7.3 sqlsrv/transaction.inc \DatabaseTransaction_sqlsrv::__destruct()

Overriden __desctur to provide some mental health.

Overrides DatabaseTransaction::__destruct

File

sqlsrv/transaction.inc, line 56

Class

DatabaseTransaction_sqlsrv
Overriden to bring some commonsense to transaction management.

Code

public function __destruct() {
  if (!$this->settings
    ->Get_Sane()) {

    // If we rolled back then the transaction would have already been popped.
    if (!$this->rolledBack) {
      $this->connection
        ->popTransaction($this->name);
    }
  }
  else {

    // If we did not commit and did not rollback explicitly, rollback.
    // Rollbacks are not usually called explicitly by the user
    // but that could happen.
    if (!$this->commited && !$this->rolledBack) {
      $this
        ->rollback();
    }
  }
}