There is a great misconception that SQLite is not available for PHP4,
rather only for PHP5. In fact, SQLite support has been around for quite
some time courtesy of the bindings available via the PHP Extension
Community Library (PECL). This tutorial is intended to show you how to
install the SQLite PECL Extension in PHP4. Following its installation I
will walk through a basic example of using SQLite to access a database
stored in a flat file.
So what is SQLite and what makes it so special? At their most basic
level the vast majority of Database Engines (MySQL, Access, SQL Server,
Postgres, etc) store their data as flat files on the file system. The
application engine exists to allow for enhanced functionality such as
user authentication, key management, etc. SQLite, however, does not
represent your typical database, primarily because it lacks such an
engine. Because of this it is unable to incorporate some of the advanced
features found in high end database engines. Rather it is designed to be
simple, easy to use, and capable of operating with decreased overhead
making it especially useful for embedded systems.
For example, in PHP when you send a query to MySQL database it follows a
client-server architecture where PHP talks to MySQL which then talks to
its flat files. SQLite on the other hand is, itself, the server and
therefore allows us to drop the middleman and have PHP talk directory to
the files where the data is stored. Step 1: Acquire and install the
software extension tarball from PECL.
This can be done either by visiting the PECL website
(http://pecl.php.net), or using the PEAR Package Manager
(pear download SQLite). Perhaps the simplest shortcut is to, from the command line, run
'pear install SQLite'. In this matter both the acquisition and
installation of the extension are completed with one simple command.
Note: When I did this, I had to do explicitly create the copy path,
listed at the end of the install process. If you encounter this problem
be sure to see what directory the installer is attempting to copy to,
create it, and run the installer again.