1. drupal
    1. 8
    2. 7
8 – 7 db_transaction($name = NULL, array $options = array())

Returns a new transaction object for the active database.


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

▾ 15 functions call db_transaction()

block_admin_configure_submit in modules/block/block.admin.inc
Form submission handler for the block configuration form.
block_admin_display_form_submit in modules/block/block.admin.inc
Form submission handler for the main blocks administration 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.
DatabaseTransactionTestCase::transactionInnerLayer in modules/simpletest/tests/database_test.test
Helper method for transaction unit tests. This "inner layer" transaction is either used alone or nested inside of the "outer layer" transaction.
DatabaseTransactionTestCase::transactionOuterLayer in modules/simpletest/tests/database_test.test
Helper method for transaction unit test. This "outer layer" transaction starts and then encapsulates the "inner layer" transaction. This nesting is used to evaluate whether the the database transaction API properly supports…
menu_rebuild in includes/menu.inc
(Re)populate the database tables used by various menu functions.
node_delete_multiple in modules/node/node.module
Delete multiple nodes.
node_save in modules/node/node.module
Save changes to a node or add a new node.
taxonomy_term_delete in modules/taxonomy/taxonomy.module
Delete a term.
taxonomy_vocabulary_delete in modules/taxonomy/taxonomy.module
Delete a vocabulary.
user_delete_multiple in modules/user/user.module
Delete multiple user accounts.
user_save in modules/user/user.module
Save changes to a user account or add a new user.
_registry_update in includes/registry.inc
Does the work for registry_update().


includes/database/database.inc, line 2504

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