You are here

protected function Connection::popCommittableTransactions in Drupal driver for SQL Server and SQL Azure 8.2

Same name and namespace in other branches
  1. 8 drivers/lib/Drupal/Driver/Database/sqlsrv/Connection.php \Drupal\Driver\Database\sqlsrv\Connection::popCommittableTransactions()
  2. 3.0.x drivers/lib/Drupal/Driver/Database/sqlsrv/Connection.php \Drupal\Driver\Database\sqlsrv\Connection::popCommittableTransactions()

Internal function: commit all the transaction layers that can commit.

Overrides Connection::popCommittableTransactions

2 calls to Connection::popCommittableTransactions()
Connection::popTransaction in drivers/lib/Drupal/Driver/Database/sqlsrv/Connection.php
Decreases the depth of transaction nesting.
Connection::rollback in drivers/lib/Drupal/Driver/Database/sqlsrv/Connection.php
Overriden.

File

drivers/lib/Drupal/Driver/Database/sqlsrv/Connection.php, line 1006
Definition of Drupal\Driver\Database\sqlsrv\Connection

Class

Connection
Temporary tables: temporary table support is done by means of global temporary tables (#) to avoid the use of DIRECT QUERIES. You can enable and disable the use of direct queries with $this->driver_settings->defaultDirectQuery =…

Namespace

Drupal\Driver\Database\sqlsrv

Code

protected function popCommittableTransactions() {

  // Commit all the committable layers.
  foreach (array_reverse($this->transactionLayers) as $name => $state) {

    // Stop once we found an active transaction.
    if ($state['active']) {
      break;
    }

    // If there are no more layers left then we should commit.
    unset($this->transactionLayers[$name]);
    if (empty($this->transactionLayers)) {
      try {

        // PDO::commit() can either return FALSE or throw an exception itself
        if (!$this->connection
          ->commit()) {
          throw new DatabaseTransactionCommitFailedException();
        }
      } finally {

        // Restore original transaction isolation level
        if ($level = $this->driver_settings
          ->GetDefaultTransactionIsolationLevelInStatement()) {
          if ($state['settings']
            ->Get_IsolationLevel() != DatabaseTransactionIsolationLevel::Ignore()) {
            if ($level != $state['settings']
              ->Get_IsolationLevel()
              ->__toString()) {
              $this
                ->query_direct("SET TRANSACTION ISOLATION LEVEL {$level}");
            }
          }
        }
      }
    }
    else {

      // Savepoints cannot be commited, only rolled back.
    }
  }
}