You want to use a relational database that doesn't involve a separate server process.
Use SQLite. This robust, powerful database program comes with PHP 5 and doesn't require running a separate server. An SQLite database is just a file. Example 10-7 creates an SQLite database, populates it with a table if it doesn't already exist, and then puts some data into the table.
Creating an SQLite database
Because SQLite databases are just regular files, all the precautions and gotchas that apply to file access in PHP apply to SQLite databases. The user that your PHP process is running as must have permission to read from and write to the location where the SQLite database is. It is an extremely good idea to make this location somewhere outside your web server's document root. If the database file can be read directly by the web server, then a user who guesses its location can retrieve the entire thing, bypassing any restrictions you've built into the queries in your PHP programs.
In PHP, the sqlite extension provides regular SQLite access as well as a PDO driver for SQLite version 2. The pdo_sqlite extension provides a PDO driver for SQLite version 3. If you're starting from scratch, use the PDO driver for SQLite 3, since it's faster and has more features. If you already have an SQLite 2 database, consider using the PDO drivers to migrate to SQLite 3.
The sqlite_master table referenced in Example 10-7 is special system table that holds information about other tables'so it's useful in determining whether a particular table exists yet. Other databases have their own ways of providing this sort of system metadata.
10.2.4. See Also
Documentation on SQLite at http://www.sqlite.org/docs.html and on sqlite_master at http://www.sqlite.org/faq.html#q9.