protected function DatabaseConnection_sqlsrv::popCommittableTransactions in Drupal driver for SQL Server and SQL Azure 7.2
Same name and namespace in other branches
- 7.3 sqlsrv/database.inc \DatabaseConnection_sqlsrv::popCommittableTransactions()
Internal function: commit all the transaction layers that can commit.
Overrides DatabaseConnection::popCommittableTransactions
2 calls to DatabaseConnection_sqlsrv::popCommittableTransactions()
- DatabaseConnection_sqlsrv::popTransaction in sqlsrv/
database.inc - Decreases the depth of transaction nesting.
- DatabaseConnection_sqlsrv::rollback in sqlsrv/
database.inc - Overriden.
File
- sqlsrv/
database.inc, line 888 - Database interface code for Microsoft SQL Server.
Class
- DatabaseConnection_sqlsrv
- Summary of DatabaseConnection_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
$commit_check = $this->connection
->commit();
if (!$commit_check) {
throw new DatabaseTransactionCommitFailedException();
}
} finally {
// Restore original transaction isolation level
if ($level = static::DefaultTransactionIsolationLevelInStatement()) {
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.
}
}
}