You are here

public static function DatabaseTransactionSettings::GetDefaults in Drupal driver for SQL Server and SQL Azure 7.2

Same name and namespace in other branches
  1. 7.3 sqlsrv/transaction.inc \DatabaseTransactionSettings::GetDefaults()

Returns a default setting system-wide.

Return value

DatabaseTransactionSettings

1 call to DatabaseTransactionSettings::GetDefaults()
DatabaseConnection_sqlsrv::startTransaction in sqlsrv/database.inc
Overriden to allow transaction settings.

File

sqlsrv/transaction.inc, line 197

Class

DatabaseTransactionSettings
Behaviour settings for a transaction.

Code

public static function GetDefaults() {

  // Use snapshot if available.
  $isolation = DatabaseTransactionIsolationLevel::Ignore();
  if ($info = \Database::getConnection()
    ->schema()
    ->getDatabaseInfo()) {
    if ($info->snapshot_isolation_state == TRUE) {

      // Some DDL operations on core will fail with snapshot.
      $isolation = DatabaseTransactionIsolationLevel::ReadCommitted();
    }
  }

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