You are here

public static function TransactionSettings::GetBetterDefaults in Drupal driver for SQL Server and SQL Azure 8.2

Same name and namespace in other branches
  1. 8 drivers/lib/Drupal/Driver/Database/sqlsrv/TransactionSettings.php \Drupal\Driver\Database\sqlsrv\TransactionSettings::GetBetterDefaults()

Proposed better defaults. Use Snapshot isolation when available and implicit commits.

Return value

TransactionSettings

1 call to TransactionSettings::GetBetterDefaults()
Insert::execute in drivers/lib/Drupal/Driver/Database/sqlsrv/Insert.php
Executes the insert query.

File

drivers/lib/Drupal/Driver/Database/sqlsrv/TransactionSettings.php, line 97

Class

TransactionSettings
Behaviour settings for a transaction.

Namespace

Drupal\Driver\Database\sqlsrv

Code

public static function GetBetterDefaults() {

  // Use snapshot if available.
  $isolation = DatabaseTransactionIsolationLevel::Ignore();

  /** @var Connection */
  $connection = Database::getConnection();
  if ($info = $connection
    ->Scheme()
    ->getDatabaseInfo($connection
    ->getDatabaseName())) {
    if ($info->snapshot_isolation_state == true) {
      $isolation = DatabaseTransactionIsolationLevel::Snapshot();
    }
  }

  // Otherwise use Drupal's default behaviour (except for nesting!)
  return new TransactionSettings(true, DatabaseTransactionScopeOption::Required(), $isolation);
}