function db_transaction

7.x database.inc db_transaction($name = NULL, array $options = array())
8.x database.inc db_transaction($name = NULL, array $options = array())

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 drupal/modules/block/block.admin.inc
Form submission handler for block_admin_configure().
block_admin_display_form_submit in drupal/modules/block/block.admin.inc
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

File

drupal/includes/database/database.inc, line 2571
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);
}