DatabaseConnection::popTransaction

  1. drupal
    1. 7
Versions
7 public DatabaseConnection::popTransaction($name)

Decreases the depth of transaction nesting.

If we pop off the last transaction layer, then we either commit or roll back the transaction as necessary. If no transaction is active, we return because the transaction may have manually been rolled back.

@throws DatabaseTransactionCommitFailedException

Parameters

$name The name of the savepoint

Throws

DatabaseTransactionNoActiveException

See also

DatabaseTransaction

Code

drupal/includes/database/database.inc, line 1014

<?php
public function popTransaction($name) {
  if (!$this->supportsTransactions()) {
    return;
  }
  if (!$this->inTransaction()) {
    throw new DatabaseTransactionNoActiveException();
  }

  // Commit everything since SAVEPOINT $name.
  while ($savepoint = array_pop($this->transactionLayers)) {
    if ($savepoint != $name) {
      continue;
    }

    // If there are no more layers left then we should commit.
    if (empty($this->transactionLayers)) {
      if (!parent::commit()) {
        throw new DatabaseTransactionCommitFailedException();
      }
    }
    else {
      $this->query('RELEASE SAVEPOINT ' . $name);
      break;
    }
  }
}
?>