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

(singke) #1

if(dba_exists('3', $db))
{


// remove item 3
dba_delete('3', $db);
}
else
{
print('Record does not exist');
}


// close database
dba_close($db);
}
else
{
print('Database does not exist');
}
?>


boolean dba_exists(string key, integer link)


The dba_exists function tests for the presence of a key. The link argument must be an
integer returned by the dba_open or dba_popen functions. The description of
dba_delete has an example of using dba_exists.


string dba_fetch(string key, integer link)


Use the dba_fetch function to retrieve a record.


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


if($db)
{
//loop over each record
for($key = dba_firstkey($db); $key; $key=dba_nextkey($db))
{
print("$key = ");


//fetch this record
print(dba_fetch($key, $db));


print("
\n");
}
}
else
{
print('Database does not exist');
}

Free download pdf