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

(singke) #1

boolean dbase_replace_record(integer database, array record,
integer record_number)


Use dbase_replace_record to change the contents of a record. The record argument
must have one element for each field defined in the database. Record numbers start
counting at one.


<?
$db = dbase_open("customer.dbf", 2);


$Record = array("John Smith", 200.00, "19990901","Y");
dbase_replace_record($db, $Record, 1);


dbase_close($db);
?>


DBM-style Database Abstraction


The DBA functions abstract communications with databases that conform to the style of
Berkeley DB database systems. Rather than storing complex records, a DBM database
simply stores key/value pairs. This is similar to an associative array.


The functions in this section replace a set of functions that allow just one type of DBM
database. These new functions allow for choosing the underlying system from within
your PHP code rather than compiling PHP for a single DBM implementation. You
choose a type of database when you open a connection, and the rest of the functions
perform accordingly. Sascha Schumann added these functions to PHP.


dba_close(integer link)


The dba_close function closes a link to a database. The link argument is an integer
returned by the dba_open or dba_popen functions. If you choose not to close a database
connection, PHP will close it for you.


boolean dba_delete(string key, integer link)


The dba_delete function removes an entry from a database. You must supply both the
key and a valid link to a database, as supplied by dba_open or dba_popen. The success of
the delete is returned as a boolean.


<?
// open database in write mode
$db = dba_popen('inventory', 'w', 'gdbm');


if($db)
{
//check for record

Free download pdf