PHP Developer’s Dictionary IT-SC book 390 The dba_exists() function, which was added in PHP 3.0.8 and PHP 4.0b2, checks for the existence of an entry with key in the database specified by the handle parameter. The return value is TRUE if the key is found and FALSE otherwise. dba_fetch() Syntax string dba_fetch (string key, int handle) Description The dba_fetch() function, which was added in PHP 3.0.8 and PHP 4.0b2, returns the data associated with the key in the database referenced by the handle . If the key is found, its data value is returned, and FALSE is returned otherwise. dba_firstkey() Syntax string dba_firstkey (int handle) Description The dba_firstkey() function, which was added in PHP 3.0.8 and PHP 4.0b2, returns the first key in the database referenced by the handle parameter. It also resets an internal key pointer to the first item in the database, which is useful when performing a linear search. The return value is the first key, or FALSE if no key is found. dba_insert() Syntax bool dba_insert (string key, string value, int handle) Description The dba_insert() function, which was added in PHP 3.0.8 and PHP 4.0b2, inserts an entry into the database referenced by the handle parameter. The entry is comprised PHP Developer’s Dictionary IT-SC book 391 of the key and value parameters. If the key already exists in the database, FALSE is returned; otherwise, TRUE is returned. dba_nextkey() Syntax string dba_nextkey (int handle ) Description The dba_nextkey() function, which was added in PHP 3.0.8 and PHP 4.0b2, returns the value of the next key in the database referenced by the handle parameter. The internal key pointer is also incremented. The key value is returned if successful, and FALSE is returned otherwise. dba_open() Syntax int dba_open (string path, string mode, string handler [, ]) Description The dba_open() function, which was added in PHP 3.0.8 and PHP 4.0b2, is used to open a connection to a database. The path parameter represents a regular path in the filesystem. The mode parameter can be one of four options: 'r' for read access, 'w' for read/write access to an existing database, 'c' for read/write and creation, or 'n' for create, read/write, and truncate. The parameter handler represents the name of the handler that will be used to access the path . The handler is passed any optional parameters that are supplied. An example of a handler is 'gdbm' . The return value is a handle to the database, or FALSE if the connection fails. dba_optimize() Syntax bool dba_optimize (int handle) Description PHP Developer’s Dictionary IT-SC book 392 The dba_optimize() function, which was added in PHP 3.0.8 and PHP 4.0b2, optimizes the database referenced by the handle parameter. The return value is TRUE for a successful optimization and FALSE otherwise. dba_popen() Syntax int dba_popen (string path, string mode, string handler [, ]) Description The dba_popen() function, which was added in PHP 3.0.8 and PHP 4.0b2, is used to open a persistent connection to a database. The path parameter represents a regular path in the filesystem. The mode parameter can be one of four options: 'r' for read access, 'w' for read/write access to an existing database, 'c' for read/write and creation, or 'n' for create, read/write, and truncate. The parameter handler represents the name of the handler that will be used to access the path . The handler is passed any optional parameters that are supplied. An example of a handler is 'gdbm'. The return value is a handle to the database, or FALSE if the connection fails. dba_replace() Syntax bool dba_replace (string key, string value, int handle) Description The dba_replace() function, which was added in PHP 3.0.8 and PHP 4.0b2, replaces or inserts an entry into the database referenced by the handle parameter. The entry is comprised of the key and value parameters. The return value is TRUE on success and FALSE otherwise. dba_sync() Syntax bool dba_sync (int handle) PHP Developer’s Dictionary IT-SC book 393 Description The dba_sync() function, which was added in PHP 3.0.8 and PHP 4.0b2, synchronizes the database referenced by the handle parameter. This function typically causes the changes to be written to disk. The return value is TRUE on success and FALSE otherwise. dBASE The dBASE functions enable you to interact with records stored in a .dbf file. There is no support for indexes, locking, or memo fields at this time. Because locking doesn't exist, it is very possible that two concurrent processes could damage the database. dBASE files are fixed-length sequential records. Deleting a record in dBASE only causes the record to be marked for deletion; the record is not removed until dbase_pack() is called. Because dBASE doesn't support concurrent users well and has many other limitations, using dBASE is recommended only for testing purposes. The following example opens a dBASE file and dumps the contents of the first record: <? $dbase_db = dbase_open("users.dbf",0); $dbase_numfields = dbase_numfields($db); $dbase_record = dbase_get_record($dbase_db,0); for ($i=0; $i < $dbase_numfields; $i++) { print $dbase_record[$i]."<br>\ n";} $dbase_close($dbase_db); ?> dbase_create() Syntax int dbase_create (string filename, array fields) Description The dbase_create() function, which is available in PHP 3.0.16 and prior along with PHP 4.0, creates a dBASE database file. The filename parameter is used to name the new file and the fields parameter is used to specify the database columns of the file. The fields parameter should be an array of arrays, with each array describing one field in the database. Each array consists of four fields: the column name, a character indicating the column type, field length, and precision. Precision represents the number of digits after the decimal point. If creation is successful, a dbase_identifier is returned; FALSE is returned otherwise. Field Types Available PHP Developer’s Dictionary IT-SC book 394 Character Type Notes L Boolean These do not have a length or precision. M Memo These are not supported by PHP. They don't have a length or precision. D Date These are stored in the format YYYYMMDD . They do not have a length or precision. N Number These have both a length and a precision. C String These are for character data up to the length specified. $tabledef = array(array("userid,"N",8,0) "username","C",50), array("password","C",50)); dbase_create("users.dbf",$tabledef); dbase_open() Syntax int dbase_open (string filename, int flags) Description The dbase_open() function, which is available in PHP 3.0.16 and prior along with PHP 4.0, attempts to open a dBASE file and returns a dbase_identifier if successful and FALSE otherwise. The filename parameter represents the name of the dBASE file to be opened and the flags parameter is used to determine the mode in which the file should be opened. Typical flag values are 0 for read-only, 1 for write-only, and 2 for read and write. dbase_close() Syntax bool dbase_close (int dbase_identifier) Description The dbase_close() function, which is available in PHP 3.0.16 and prior along with PHP 4.0, closes the dBASE file specified by the dbase_identifier parameter. dbase_pack() . PHP Developer’s Dictionary IT-SC book 390 The dba_exists() function, which was added in PHP 3.0.8 and PHP 4.0b2, checks for the existence of an. dba_insert() function, which was added in PHP 3.0.8 and PHP 4.0b2, inserts an entry into the database referenced by the handle parameter. The entry is comprised PHP Developer’s Dictionary IT-SC book. dba_optimize (int handle) Description PHP Developer’s Dictionary IT-SC book 392 The dba_optimize() function, which was added in PHP 3.0.8 and PHP 4.0b2, optimizes the database referenced