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

Construit un objet DrupalCoreDatabaseDriversqliteConnection.

Remplace la connexion ::__construct

Déposer

core/lib/Drupal/Core/Database/Driver/sqlite/Connexion.php, ligne 49

Classer

Lien

Implémentation SQLite de DrupalCoreDatabaseConnection.

Espace de noms

DrupalCoreDatabaseDriversqlite

Code

public function __construct(PDO $connection, array $connection_options) {
  // We don't need a specific PDOStatement class here, we simulate it in
  // static::prepare().
  $this->statementClass = NULL;

  parent::__construct($connection, $connection_options);

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

  $this->connectionOptions = $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 (!empty($prefix)) {
      // Only attach the database once.
      if (!isset($this->attachedDatabases[$prefix])) {
        $this->attachedDatabases[$prefix] = $prefix;
        if ($connection_options['database'] === ':memory:') {
          // In memory database use ':memory:' as database name. According to
          // http://www.sqlite.org/inmemorydb.html it will open a unique
          // database so attaching it twice is not a problem.
          $this->query('ATTACH DATABASE :database AS :prefix', array(':database' => $connection_options['database'], ':prefix' => $prefix));
        }
        else {
          $this->query('ATTACH DATABASE :database AS :prefix', array(':database' => $connection_options['database'] . '-' . $prefix, ':prefix' => $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);
}