You are here

public function DatabaseContext::__construct in Drupal driver for SQL Server and SQL Azure 7.2

Same name and namespace in other branches
  1. 7.3 sqlsrv/context.inc \DatabaseContext::__construct()

Define the behaviour of the database driver during the scope of the life of this instance.

Parameters

DatabaseConnection_sqlsrv $connection:

Instance of the connection to be configured. Leave null to use the current default connection.

mixed $bypass_queries:

Do not preprocess the query before execution.

mixed $direct_query:

Prepare statements with SQLSRV_ATTR_DIRECT_QUERY = TRUE.

mixed $statement_caching:

Enable prepared statement caching. Cached statements are reused even after the context has expired.

File

sqlsrv/context.inc, line 61

Class

DatabaseContext
Defines a behaviour scope for the database driver that lasts until the object is destroyed.

Code

public function __construct(\DatabaseConnection_sqlsrv $connection = NULL, $bypass_queries = NULL, $direct_query = NULL, $statement_caching = NULL) {
  if ($connection == NULL) {
    $connection = Database::getConnection();
  }
  $this->connection = $connection;
  $this->state_bypass = $this->connection->bypassQueryPreprocess;
  $this->state_direct = $this->connection->directQuery;
  $this->statement_caching = $this->connection->statementCaching;
  if ($bypass_queries !== NULL) {
    $this->connection->bypassQueryPreprocess = $bypass_queries;
  }
  if ($direct_query !== NULL) {
    $this->connection->directQuery = $direct_query;
  }
  if ($statement_caching !== NULL) {
    $this->connection->statementCaching = $statement_caching;
  }
}