public function Connection::pushTransaction

public Connection::pushTransaction($name)

Increases the depth of transaction nesting.

If no transaction is already active, we begin a new transaction.

Parameters

string $name: The name of the transaction.

Throws

\Drupal\Core\Database\TransactionNameNonUniqueException

See also

\Drupal\Core\Database\Transaction

File

core/lib/Drupal/Core/Database/Connection.php, line 1116

Class

Connection
Base Database API class.

Namespace

Drupal\Core\Database

Code

public function pushTransaction($name) {
  if (!$this->supportsTransactions()) {
    return;
  }
  if (isset($this->transactionLayers[$name])) {
    throw new TransactionNameNonUniqueException($name . " is already in use.");
  }
  // If we're already in a transaction then we want to create a savepoint
  // rather than try to create another transaction.
  if ($this->inTransaction()) {
    $this->query('SAVEPOINT ' . $name);
  }
  else {
    $this->connection->beginTransaction();
  }
  $this->transactionLayers[$name] = $name;
}

© 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/core!lib!Drupal!Core!Database!Connection.php/function/Connection::pushTransaction/8.1.x