PHP provides two SQLite extensions by default since version 5.0. The latest SQLite extension is known as sqlite3 extension that is included in PHP 5.3+.
The sqlite3 extension provides an interface for accessing SQLite 3. The sqlite3 includes class interfaces to the SQL commands. In addition, it allows you to create SQL functions and aggregate using PHP.
PHP introduced the PDO interfaces since version 5.1. The PDO is the latest PHP solution that provides a unified database access interface. Note that PDO is just an abstract layer that allows you to use a common library to access any databases. In the context of SQLite, it needs sqlite3 extension to access SQLite database.
The PDO_SQLITE extension provides the PDO driver for the SQLite 3 library. It supports standard PDO interfaces, and also custom methods for creating SQL functions and aggregates using PHP.
In this section, we will walk you through the steps of using PDO to access SQLite databases.
- Connecting to SQLite database using PHP PDO – shows you how to use the PHP PDO to connect to an SQLite database.
- Creating SQLite tables using PDO – guides you how to execute the CREATE TABLE statements from PHP to create new tables in SQLite from PHP.
- Inserting data into tables using PDO – teaches you how to use insert data into the tables in SQLite3 using PHP.
- Updating data using PDO – walk you through the steps of updating data in the existing table in SQLite database using PDO.
- Querying data in SQLite database – shows you various ways to query data from the SQLite database.
- Working with SQLite3 BLOB data – shows you how to work with the SQLite BLOB data type using PHP PDO with some practical examples.
- Using transaction in PHP PDO – gives you an example of using SQLite transaction from PHP.
- Deleting data in SQLite database – provides you with steps of deleting data in SQLite database using PHP.