public function DatabaseConnection_sqlite::popTransaction

public DatabaseConnection_sqlite::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.

Parameters

$name: The name of the savepoint

Throws

DatabaseTransactionNoActiveException

DatabaseTransactionCommitFailedException

Overrides DatabaseConnection::popTransaction

See also

DatabaseTransaction

File

includes/database/sqlite/database.inc, line 349
Database interface code for SQLite embedded database engine.

Class

DatabaseConnection_sqlite
Specific SQLite implementation of DatabaseConnection.

Code

public function popTransaction($name) {
  if ($this->savepointSupport) {
    return parent::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 or rollback.
    if (empty($this->transactionLayers)) {
      // If there was any rollback() we should roll back whole transaction.
      if ($this->willRollback) {
        $this->willRollback = FALSE;
        PDO::rollBack();
      }
      elseif (!PDO::commit()) {
        throw new DatabaseTransactionCommitFailedException();
      }
    }
    else {
      break;
    }
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/includes!database!sqlite!database.inc/function/DatabaseConnection_sqlite::popTransaction/7.x