function DatabaseTransaction::__construct

File

includes/database/database.inc, line 1999

Class

DatabaseTransaction
A wrapper class for creating and managing database transactions.

Code

public function __construct(DatabaseConnection $connection, $name = NULL) {
    $this->connection = $connection;
    // If there is no transaction depth, then no transaction has started. Name
    // the transaction 'drupal_transaction'.
    if (!($depth = $connection->transactionDepth())) {
        $this->name = 'drupal_transaction';
    }
    elseif (!$name) {
        $this->name = 'savepoint_' . $depth;
    }
    else {
        $this->name = $name;
    }
    $this->connection
        ->pushTransaction($this->name);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.