class DatabaseTransactionSettings in Drupal driver for SQL Server and SQL Azure 7.3
Same name and namespace in other branches
- 7.2 sqlsrv/transaction.inc \DatabaseTransactionSettings
Behaviour settings for a transaction.
Hierarchy
- class \DatabaseTransactionSettings
Expanded class hierarchy of DatabaseTransactionSettings
File
- sqlsrv/
transaction.inc, line 137
View source
class DatabaseTransactionSettings {
/**
* Summary of __construct
* @param mixed $Sane
* @param DatabaseTransactionScopeOption $ScopeOption
* @param DatabaseTransactionIsolationLevel $IsolationLevel
*/
public function __construct($Sane = FALSE, DatabaseTransactionScopeOption $ScopeOption = NULL, DatabaseTransactionIsolationLevel $IsolationLevel = NULL) {
$this->_Sane = $Sane;
if ($ScopeOption == NULL) {
$ScopeOption = DatabaseTransactionScopeOption::RequiresNew();
}
if ($IsolationLevel == NULL) {
$IsolationLevel = DatabaseTransactionIsolationLevel::Unspecified();
}
$this->_IsolationLevel = $IsolationLevel;
$this->_ScopeOption = $ScopeOption;
}
// @var DatabaseTransactionIsolationLevel
private $_IsolationLevel;
// @var DatabaseTransactionScopeOption
private $_ScopeOption;
// @var Boolean
private $_Sane;
/**
* Summary of Get_IsolationLevel
* @return mixed
*/
public function Get_IsolationLevel() {
return $this->_IsolationLevel;
}
/**
* Summary of Get_ScopeOption
* @return mixed
*/
public function Get_ScopeOption() {
return $this->_ScopeOption;
}
/**
* Summary of Get_Sane
* @return mixed
*/
public function Get_Sane() {
return $this->_Sane;
}
/**
* Returns a default setting system-wide.
*
* @return DatabaseTransactionSettings
*/
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);
}
/**
* Proposed better defaults.
*
* @return DatabaseTransactionSettings
*/
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);
}
/**
* Snapshot isolation is not compatible with DDL operations.
*
* @return DatabaseTransactionSettings
*/
public static function GetDDLCompatibleDefaults() {
return new DatabaseTransactionSettings(TRUE, DatabaseTransactionScopeOption::Required(), DatabaseTransactionIsolationLevel::ReadCommitted());
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DatabaseTransactionSettings:: |
private | property | ||
DatabaseTransactionSettings:: |
private | property | ||
DatabaseTransactionSettings:: |
private | property | ||
DatabaseTransactionSettings:: |
public static | function | Proposed better defaults. | |
DatabaseTransactionSettings:: |
public static | function | Snapshot isolation is not compatible with DDL operations. | |
DatabaseTransactionSettings:: |
public static | function | Returns a default setting system-wide. | |
DatabaseTransactionSettings:: |
public | function | Summary of Get_IsolationLevel | |
DatabaseTransactionSettings:: |
public | function | Summary of Get_Sane | |
DatabaseTransactionSettings:: |
public | function | Summary of Get_ScopeOption | |
DatabaseTransactionSettings:: |
public | function | Summary of __construct |