O'Reilly logo

PHP in a Nutshell by Paul Hudson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

SQLite

SQLite is a fully functional relational database system that does not use the traditional client/server database architecture. For example, MySQL has a server running on a machine somewhere, and a client (in the form of PHP, in our examples) connects to that server to perform queries. SQLite, on the other hand, works on local files, with no database server required—when you run queries using SQLite, they are translated into operations on the local files.

From PHP 5 onward, SQLite is bundled and enabled by default, which means that everyone, everywhere, will have it by default. If you are writing an application that needs a data store, you no longer need to worry whether they have Oracle or Microsoft SQL Server installed or, indeed, whether they have any database server installed at all.

Before You Begin

SQLite uses a file for every database you create, which means that it is very easy to keep track of your data, particularly if you want to back up and restore information. However, it also means that this file must be easily available, preferably local—using remote file systems, such as NFS, is not recommended.

There are some unique aspects to SQLite that you should be aware of—the most important is its handling of field types. SQLite does not distinguish between data types beyond "string" and "number"—CHAR(255), for example, is the same as VARCHAR(20), which is the same as TEXT, which makes it typeless like PHP. This boils down to "If your data type has CHAR, TEXT, BLOB, or ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required