function Transaction::rollBack

Same name in other branches
  1. 9 core/lib/Drupal/Core/Database/Transaction.php \Drupal\Core\Database\Transaction::rollBack()
  2. 10 core/lib/Drupal/Core/Database/Transaction.php \Drupal\Core\Database\Transaction::rollBack()
  3. 11.x core/lib/Drupal/Core/Database/Transaction.php \Drupal\Core\Database\Transaction::rollBack()

Rolls back the current transaction.

This is just a wrapper method to rollback whatever transaction stack we are currently in, which is managed by the connection object itself. Note that logging (preferable with watchdog_exception()) needs to happen after a transaction has been rolled back or the log messages will be rolled back too.

See also

\Drupal\Core\Database\Connection::rollBack()

watchdog_exception()

File

core/lib/Drupal/Core/Database/Transaction.php, line 94

Class

Transaction
A wrapper class for creating and managing database transactions.

Namespace

Drupal\Core\Database

Code

public function rollBack() {
    $this->rolledBack = TRUE;
    $this->connection
        ->rollBack($this->name);
}

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