function Connection::__construct

Constructs a \Drupal\sqlite\Driver\Database\sqlite\Connection object.

Parameters

object $connection: An object of the client 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

core/modules/sqlite/src/Driver/Database/sqlite/Connection.php, line 85

Class

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

Namespace

Drupal\sqlite\Driver\Database\sqlite

Code

public function __construct(\PDO $connection, array $connection_options) {
  parent::__construct($connection, $connection_options);
  // Attach one database for each registered prefix.
  $prefixes = $this->prefixes;
  foreach ($prefixes as &$prefix) {
    // Empty prefix means query the main database -- no need to attach
    // anything.
    if ($prefix !== '') {
      $this->attachDatabase($prefix);
      // Add a ., so queries become prefix.table, which is proper syntax for
      // querying an attached database.
      $prefix .= '.';
    }
  }
  // Regenerate the prefixes replacement table.
  $this->setPrefix($prefixes);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.