Beneath the Abstraction
To use the DBA functions, you need to have one of the supported database systems installed. If you are running Linux, you probably have the GNU Database Manager (GDBM) installed. For each system, there is a corresponding compile option that should have been used when PHP was installed. You can see the supported databases and their corresponding compile options in Table 12.1.
Table 12.1. DBM Systems Supported by the DBA Functions
Read-only database system
Read/write when bundled version is used; no updates allowed
http://www.sleepycat.com/ (since PHP 5)
The original DBM; deprecated
GNU Database Manager
Backward compatibility; use is discouraged
For management of .ini files (for example, php.ini)
If your system and PHP installation support one of these systems, you can use the DBA functions with no problems. Note that support for the cdbm system (which is designed for fast access to static databases) is read-only. If you have not compiled PHP with support for any of the DBA handlers listed in Table 12.1, your script will fail with an error when you attempt to use any of the DBA functions.
You can check the handlers available to you with the dba_handlers() function. This returns an array of handler names. Adding the following to a script gives you a quick listing of available handlers:
var_dump( dba_handlers() );
You could also use the phpinfo() function. The phpinfo() output page has a section on DBA that lists handlers and confirms that DBA support is enabled.
The dba_handlers() function was introduced with PHP 4.3.
We will use the commonly available GDBM system in our examples.