Microsoft Word - Core PHP Programming Using PHP to Build Dynamic Web Sites

(singke) #1

php_dbase.dll but was unavailable at the time of this writing. On other operating
systems it's easy to compile dBase support into PHP.


The dBase functionality in PHP is somewhat limited. Index and memo fields are not
supported. Neither is any kind of locking. The dBase functionality in PHP is meant to be
a means of importing data from what has become somewhat of a lowest common
denominator in data exchange.


Jim Winstead added dBase support to PHP.


boolean dbase_add_record(integer database, array record)


The dbase_add_record function adds a record to the database specified by a database
identifier returned by dbase_open. The record array contains an element for each field in
the database, in order and starting at zero. If the correct number of fields is not supplied,
FALSE is returned.


<?
//open connection to database
$db = dbase_open("customer.dbf", 2);


//create record to be added
$newRecord = array("John Smith", 100.00, "19980901","Y");


//add record
dbase_add_record($db, $newRecord);


//close connection
dbase_close($db);
?>


boolean dbase_close(integer database)


The dbase_close function closes a database. See other functions in this section for
examples of use.


integer dbase_create(string filename, array fields)


The dbase_create function creates a dBase database. The fields argument is an array of
arrays that describe fields. Each array may have up to four elements. In order, they are
name, type, length, and precision. Type is a single character. Some types require
length, and precision; others do not. See Table 13.1.


Table 13.1. dBase Field Types
Type Code Description

BooleanL^ This type does not have a length or a precision.

Free download pdf