You are here

public function Transaction::commit 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::commit()

Commits the transaction. Only available for SANE transactions.

Throws

DatabaseTransactionExplicitCommitNotAllowedException

File

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

Class

Transaction

Namespace

Drupal\Driver\Database\sqlsrv

Code

public function commit() {

  // Insane transaction behaviour does not allow explicit commits.
  if (!$this->settings
    ->Get_Sane()) {
    throw new DatabaseTransactionExplicitCommitNotAllowedException();
  }

  // Cannot commit a rolledback transaction...
  if ($this->rolledBack) {
    throw new DatabaseTransactionCannotCommitAfterRollbackException();
  }

  // Mark as commited, and commit!
  $this->commited = TRUE;

  // Do not pop the transaction if this features is not enabled.
  if ($this->connection->driver_settings
    ->GetEnableTransactions() === FALSE) {
    return;
  }

  // Finally pop it!
  $this->connection
    ->popTransaction($this->name);
}