function Connection::inTransaction

Same name in other branches
  1. 9 core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::inTransaction()
  2. 8.9.x core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::inTransaction()
  3. 11.x core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::inTransaction()

Determines if there is an active transaction open.

Return value

bool TRUE if we're currently in a transaction, FALSE otherwise.

2 calls to Connection::inTransaction()
Connection::pushTransaction in core/lib/Drupal/Core/Database/Connection.php
Increases the depth of transaction nesting.
Connection::rollBack in core/lib/Drupal/Core/Database/Connection.php
Rolls back the transaction entirely or to a named savepoint.

File

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

Class

Connection
Base Database API class.

Namespace

Drupal\Core\Database

Code

public function inTransaction() {
    if ($this->transactionManager()) {
        return $this->transactionManager()
            ->inTransaction();
    }
    // Start of BC layer.
    // @phpstan-ignore-next-line
    return $this->transactionDepth() > 0;
    // End of BC layer.
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.