function Connection::commit

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

Throws an exception to deny direct access to transaction commits.

We do not want to allow users to commit transactions at any time, only by destroying the transaction object or allowing it to go out of scope. A direct commit bypasses all of the safety checks we've built on top of the database client's transaction routines.

Throws

\Drupal\Core\Database\TransactionExplicitCommitNotAllowedException

Deprecated

in drupal:10.2.0 and is removed from drupal:11.0.0. Do not commit the connection, void the Transaction objects instead.

See also

\Drupal\Core\Database\Transaction

https://www.drupal.org/node/3381002

File

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

Class

Connection
Base Database API class.

Namespace

Drupal\Core\Database

Code

public function commit() {
    @trigger_error(__METHOD__ . '() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Do not commit the connection, void the Transaction objects instead. See https://www.drupal.org/node/3381002', E_USER_DEPRECATED);
    throw new TransactionExplicitCommitNotAllowedException();
}

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