[ Team LiB ] Previous Section Next Section

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

Type

Compile Option

Further Information

cdbm

--with-cdbm

Read-only database system

cdb

--with-cdb

Read/write when bundled version is used; no updates allowed

db2

--with-db2

http://www.sleepycat.com/

db3

--with-db3

http://www.sleepycat.com/

db4

--with-db4

http://www.sleepycat.com/ (since PHP 5)

dbm

--with-dbm

The original DBM; deprecated

gdbm

--with-gdbm

GNU Database Manager

ndbm

--with-ndbm

Deprecated

flatfile

--with-flatfile

Backward compatibility; use is discouraged

inifile

--with-inifile

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.

graphics/bytheway_icon.gif

The dba_handlers() function was introduced with PHP 4.3.


We will use the commonly available GDBM system in our examples.

    [ Team LiB ] Previous Section Next Section