?>
string dba_firstkey(integer link)
The dba_firstkey function returns the first key in the database. If the database is empty,
FALSE will be returned. As the example for dba_fetch shows, dba_firstkey and
dba_nextkey may be used to traverse the entire database.
boolean dba_insert(string key, string value, integer link)
Use dba_insert to add a record to the database. The success of the insert is returned.
Trying to insert a record that already exists is not allowed. If you need to update a record,
use dba_replace.
<?
// open database in write mode
$db = dba_popen('inventory', 'w', 'gdbm');
if($db)
{
//check for record
if(dba_exists('3', $db))
{
//item 3 exists, set inventory to 150
dba_replace('3', '150', $db);
}
else
{
//item 3 doesn't exists, insert it
dba_insert('3', '150', $db);
}
// close database
dba_close($db);
}
else
{
print('Database does not exist');
}
?>
string dba_nextkey(integer link)
The dba_nextkey function returns the next key from the database. When there are no
keys left, false is returned. The description of dba_fetch shows a typical use of
dba_nextkey and dba_firstkey together.