You are here

public function Transaction::__destruct in Drupal driver for SQL Server and SQL Azure 8

Same name and namespace in other branches
  1. 8.2 drivers/lib/Drupal/Driver/Database/sqlsrv/Transaction.php \Drupal\Driver\Database\sqlsrv\Transaction::__destruct()

Overriden __destruct to provide some mental health (sane support).

Overrides Transaction::__destruct

File

drivers/lib/Drupal/Driver/Database/sqlsrv/Transaction.php, line 80
Definition of Drupal\Driver\Database\sqlsrv\Transaction

Class

Transaction

Namespace

Drupal\Driver\Database\sqlsrv

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();
    }
  }
}