You are here

public function Transaction::__construct in Drupal driver for SQL Server and SQL Azure 8

Same name and namespace in other branches
  1. 8.2 drivers/lib/Drupal/Driver/Database/sqlsrv/Transaction.php \Drupal\Driver\Database\sqlsrv\Transaction::__construct()

Overriden to add settings.

Parameters

Connection $connection:

string $name:

DatabaseTransactionSettings $settings:

Overrides Transaction::__construct

File

drivers/lib/Drupal/Driver/Database/sqlsrv/Transaction.php, line 48
Definition of Drupal\Driver\Database\sqlsrv\Transaction

Class

Transaction

Namespace

Drupal\Driver\Database\sqlsrv

Code

public function __construct(Connection $connection, $name = NULL, DatabaseTransactionSettings $settings = NULL) {

  // Store connection and settings.
  $this->settings = $settings;
  $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 (empty($name)) {
    $this->name = 'savepoint_' . $depth;
  }
  else {
    $this->name = $name;
  }

  // Do not push the transaction if this features is not enable.
  if ($this->connection->driver_settings
    ->GetEnableTransactions() === FALSE) {
    return;
  }
  $this->connection
    ->pushTransaction($this->name, $settings);
}