protected function ConnectionFactory::sqliteDatabases in Dbal connection 8
SQLite attach prefixes as databases.
Parameters
\Doctrine\DBAL\Driver\Connection $connection: The connection to an SQLite database.
array $prefixes: Drupal info array of database prefixes.
string $base_db: The connected dbname.
See also
Drupal\Core\Database\Driver\sqlite\Connection::__construct()
1 call to ConnectionFactory::sqliteDatabases()
- ConnectionFactory::get in src/ConnectionFactory.php 
- Gets a DBAL connection to the given target.
File
- src/ConnectionFactory.php, line 95 
Class
- ConnectionFactory
- Provides a connection factory for connection to databases via doctrine/dbal.
Namespace
Drupal\dbalCode
protected function sqliteDatabases(Connection $connection, array $prefixes, $base_db) {
  $attached = [];
  foreach ($prefixes as $prefix) {
    if (!isset($attached[$prefix])) {
      $attached[$prefix] = TRUE;
      $query = $connection
        ->prepare('ATTACH DATABASE :db AS :prefix');
      if ($base_db == ':memory:') {
        $query
          ->execute([
          ':db' => $base_db,
          ':prefix' => $prefix,
        ]);
      }
      else {
        $query
          ->execute([
          ':db' => $base_db . '-' . $prefix,
          ':prefix' => $prefix,
        ]);
      }
    }
  }
}