SQLite Functions (PDO_SQLITE)SQLite (PDO)
&reftitle.intro;
PDO_SQLITE is a driver that implements the PHP
Data Objects (PDO) interface to enable access to SQLite 3 databases.
In PHP 5.1, the SQLite extension also
provides a driver for SQLite 2 databases; while it is not technically a
part of the PDO_SQLITE driver, it behaves similarly, so it is
documented alongside it. The SQLite 2 driver for PDO is provided
primarily to make it easier to import legacy SQLite 2 database files into
an application that uses the faster, more efficient SQLite 3 driver. As
a result, the SQLite 2 driver is not as feature-rich as the SQLite 3
driver.
PDO_SQLITE allows using strings apart from streams together with
PDO::PARAM_LOB.
&reference.pdo-sqlite.configure;
PDO_SQLITE DSNConnecting to SQLite databases
&reftitle.description;
The PDO_SQLITE Data Source Name (DSN) is composed of the following elements:
DSN prefix (SQLite 3)
The DSN prefix is sqlite:.
To access a database on disk, append the absolute path to the
DSN prefix.
To create a database in memory, append :memory:
to the DSN prefix.
DSN prefix (SQLite 2)
The SQLite extension in
PHP 5.1 provides a PDO driver that supports accessing and creating SQLite 2
databases. This enables you to access databases you may have created
with the SQLite extension in
previous versions of PHP.
The sqlite2 driver is only available in PHP 5.1.x if you have enabled
both PDO and ext/sqlite. It is not currently available via PECL.
The DSN prefix for connecting to SQLite 2 databases is
sqlite2:.
To access a database on disk, append the absolute path to the
DSN prefix.
To create a database in memory, append :memory:
to the DSN prefix.
&reftitle.examples;
PDO_SQLITE DSN examples
The following examples show PDO_SQLITE DSN for connecting to
SQLite databases:
&reference.pdo-sqlite.entities.PDO;