public function Connection::__construct

public Connection::__construct(\PDO $connection, array $connection_options)

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.

File

core/lib/Drupal/Core/Database/Connection.php, line 154

Class

Connection
Base Database API class.

Namespace

Drupal\Core\Database

Code

public function __construct(\PDO $connection, array $connection_options) {
  // Initialize and prepare the connection prefix.
  $this->setPrefix(isset($connection_options['prefix']) ? $connection_options['prefix'] : '');

  // Set a Statement class, unless the driver opted out.
  if (!empty($this->statementClass)) {
    $connection->setAttribute(\PDO::ATTR_STATEMENT_CLASS, array($this->statementClass, array($this)));
  }

  $this->connection = $connection;
  $this->connectionOptions = $connection_options;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Database!Connection.php/function/Connection::__construct/8.1.x