Preparations and Settings
Installation of the dba extension is rather easy. As always, Windows users have an easy job. The ext subdirectory of the PHP installation contains the module in binary, compiled form: the file php_dba.dll. The following entry in php.ini does the trick:
Then you have to decide which of the available database handlers you would like to use with PHP's dba functions. Each of these handler has its advantages and disadvantages, and not every handler works on every system, so PHP loses a bit of its portability here. A possibility exists that the handler we are using in the sample code in this chapter does not work on your specific system. To make these scripts more portable, we have created an include file handler.inc.php with the content from Listing 26.1:
Listing 26.1. The Include File for the dba Handler Used
<?php $dbahandler = "flatfile"; ?>
In all scripts, this file is included so that the variable $dbahandler contains the name of the used handler:
This way, you have to change only one file to make all examples work on your machine.
Table 26.1 shows a complete list of all available dba handlers.
Unix, Linux, and Mac users have to install at least one of those formats to use PHP's dba functions. Windows users who work with the precompiled PHP binaries have to use what the system offers them; as of time of writing, the supported dba handlers are cdb (and cdb_make), db3, inifile, and flatfile. Figure 26.1 shows a part of the output of phpinfo(): The installation was successful.
Figure 26.1. Success: The dba functions are available.