You are here

public function Connection::__construct in Drupal driver for SQL Server and SQL Azure 3.0.x

Same name and namespace in other branches
  1. 8.2 drivers/lib/Drupal/Driver/Database/sqlsrv/Connection.php \Drupal\Driver\Database\sqlsrv\Connection::__construct()
  2. 8 drivers/lib/Drupal/Driver/Database/sqlsrv/Connection.php \Drupal\Driver\Database\sqlsrv\Connection::__construct()

Constructs a Connection object.

Parameters

\PDO $connection: An object of the PDO class representing a database connection.

array $connection_options: An array of options for the connection. May include the following:

  • prefix
  • namespace
  • Other driver-specific options.

An 'extra_prefix' option may be present to allow BC for attaching per-table prefixes, but it is meant for internal use only.

Overrides Connection::__construct

File

drivers/lib/Drupal/Driver/Database/sqlsrv/Connection.php, line 265

Class

Connection
Sqlsvr implementation of \Drupal\Core\Database\Connection.

Namespace

Drupal\Driver\Database\sqlsrv

Code

public function __construct(\PDO $connection, array $connection_options) {
  $connection
    ->setAttribute(\PDO::ATTR_STRINGIFY_FETCHES, TRUE);
  parent::__construct($connection, $connection_options);

  // This driver defaults to transaction support, except if explicitly passed
  // FALSE.
  $this->transactionSupport = !isset($connection_options['transactions']) || $connection_options['transactions'] !== FALSE;
  $this->transactionalDDLSupport = $this->transactionSupport;

  // Store connection options for future reference.
  $this->connectionOptions = $connection_options;
}