function db_transaction

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

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

... See full list


drupal/includes/database/, line 2594
Core systems for the database layer.


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