Constructs a \Drupal\Core\Database\Driver\sqlite\Connection object.
Overrides Connection::__construct
public function __construct(PDO $connection, array $connection_options) {
parent::__construct($connection, $connection_options);
// We don't need a specific PDOStatement class here, we simulate it below.
$this->statementClass = NULL;
// 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 $table => &$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;
$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);
// Detect support for SAVEPOINT.
$version = $this
->query('SELECT sqlite_version()')
->fetchField();
$this->savepointSupport = version_compare($version, '3.6.8') >= 0;
}