Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Connection.php

function Connection::__construct

Same name in this branch
  1. 11.1.x vendor/symfony/var-dumper/Server/Connection.php \Symfony\Component\VarDumper\Server\Connection::__construct()
  2. 11.1.x core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::__construct()
  3. 11.1.x core/modules/sqlite/src/Driver/Database/sqlite/Connection.php \Drupal\sqlite\Driver\Database\sqlite\Connection::__construct()
  4. 11.1.x core/modules/mysql/src/Driver/Database/mysql/Connection.php \Drupal\mysql\Driver\Database\mysql\Connection::__construct()

Constructs a connection object.

Overrides Connection::__construct

File

core/modules/pgsql/src/Driver/Database/pgsql/Connection.php, line 94

Class

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

Namespace

Drupal\pgsql\Driver\Database\pgsql

Code

public function __construct(\PDO $connection, array $connection_options) {
    // Sanitize the schema name here, so we do not have to do it in other
    // functions.
    if (isset($connection_options['schema']) && $connection_options['schema'] !== 'public') {
        $connection_options['schema'] = preg_replace('/[^A-Za-z0-9_]+/', '', $connection_options['schema']);
    }
    // We need to set the connectionOptions before the parent, because setPrefix
    // needs this.
    $this->connectionOptions = $connection_options;
    parent::__construct($connection, $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']));
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal