W3cubDocs

/Drupal 8

public function Connection::__construct

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

Constructs a connection object.

Overrides Connection::__construct

File

core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php, line 53

Class

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

Namespace

Drupal\Core\Database\Driver\pgsql

Code

public function __construct(\PDO $connection, array $connection_options) {
  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);

  // Transactional DDL is always available in PostgreSQL,
  // but we'll only enable it if standard transactions are.
  $this->transactionalDDLSupport = $this->transactionSupport;

  $this->connectionOptions = $connection_options;

  // Force PostgreSQL to use the UTF-8 character set by default.
  $this->connection->exec("SET NAMES 'UTF8'");

  // Execute PostgreSQL init_commands.
  if (isset($connection_options['init_commands'])) {
    $this->connection->exec(implode('; ', $connection_options['init_commands']));
  }
}

© 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!Driver!pgsql!Connection.php/function/Connection::__construct/8.1.x