Same name and namespace in other branches
  1. 8.9.x core/includes/database.inc \db_transaction()

Returns a new transaction object for the active database.

Parameters

string $name: Optional name of the transaction.

array $options: An array of options to control how the transaction operates:

  • target: The database target name.

Return value

DatabaseTransaction A new DatabaseTransaction object for this connection.

Related topics

17 calls to db_transaction()
block_admin_configure_submit in modules/block/block.admin.inc
Form submission handler for block_admin_configure().
block_admin_display_form_submit in modules/block/block.admin.inc
Form submission handler for block_admin_display_form().
comment_delete_multiple in modules/comment/comment.module
Delete comments and all their replies.
comment_save in modules/comment/comment.module
Accepts a submission of new or changed comment content.
DatabaseTransactionTestCase::testTransactionStacking in modules/simpletest/tests/database_test.test
Test transaction stacking and commit / rollback.

... See full list

File

includes/database/database.inc, line 2655
Core systems for the database layer.

Code

function db_transaction($name = NULL, array $options = array()) {
  if (empty($options['target'])) {
    $options['target'] = 'default';
  }
  return Database::getConnection($options['target'])
    ->startTransaction($name);
}