1 database.inc db_transaction($name = NULL, array $options = array())

Returns a new transaction object for the active database.

Parameters

string|null $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

File

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