|
|
 |
XX. DBM Functions [deprecated]
These functions allow you to store records stored in a dbm-style
database. This type of database (supported by the Berkeley DB,
GDBM, and some system libraries,
as well as a built-in flatfile library) stores key/value pairs
(as opposed to the full-blown records supported by relational
databases).
To use this functions you have to compile PHP with support for an
underlying database. See the
list of supported Databases.
In order to use these functions, you must compile PHP with dbm support
by using the --with-db option. In
addition you must ensure support
for an underlying database or you can use some system libraries.
The function dbmopen() returns an database identifier
which is used by the other dbm-functions.
例子 1. DBM example |
<?php
$dbm = dbmopen("lastseen", "w");
if (dbmexists($dbm, $userid)) {
$last_seen = dbmfetch($dbm, $userid);
} else {
dbminsert($dbm, $userid, time());
}
do_stuff();
dbmreplace($dbm, $userid, time());
dbmclose($dbm);
?>
|
|
- 目录
- dblist --
Describes the DBM-compatible library being used
- dbmclose -- Closes a dbm database
- dbmdelete --
Deletes the value for a key from a DBM database
- dbmexists --
Tells if a value exists for a key in a DBM database
- dbmfetch --
Fetches a value for a key from a DBM database
- dbmfirstkey --
Retrieves the first key from a DBM database
- dbminsert --
Inserts a value for a key in a DBM database
- dbmnextkey --
Retrieves the next key from a DBM database
- dbmopen -- Opens a DBM database
- dbmreplace --
Replaces the value for a key in a DBM database
add a note
User Contributed Notes
DBM Functions [deprecated]
mouse at bloodletting dot com
07-Jul-2001 09:23
Be advised that almost every function in this section either has no
documentation or incorrectly documented regarding return codes. If you
want to use the DB methods safely you will have to reverse engineer the
return codes and hope that they do not change values returned by the
functions in the future to match the incorrect documentation.
In
my experience, the return code of 0 or FALSE indicates no error. This
matches the behavior of GDBM which I am using as my underlying DB manager.
This may not be true for people using another manager, or the builtin
flatfile code.
| |