You are here

public static function DatabaseTransactionSettings::GetBetterDefaults 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::GetBetterDefaults()

Proposed better defaults.

Return value

DatabaseTransactionSettings

2 calls to DatabaseTransactionSettings::GetBetterDefaults()
db_transaction_sane in sqlsrv/transaction.inc
Like db_transaction() but transaction behaviour is more sane requiring explicit commits.
InsertQuery_sqlsrv::execute in sqlsrv/query.inc
Executes the insert query.

File

sqlsrv/transaction.inc, line 217

Class

DatabaseTransactionSettings
Behaviour settings for a transaction.

Code

public static function GetBetterDefaults() {

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

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