★ wanayoo — archive 1999 http://www.php.net/manual/function.dbmopen.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to DBM
Quick Reference
DBM
* dbmopen
* dbmclose
* dbmexists
* dbmfetch
* dbminsert
* dbmreplace
* dbmdelete
* dbmfirstkey
* dbmnextkey
* dblist
Manual: dbmopen
View the source code for this pageSearch the site



Previous page
 DBM
dbmclose 
Next page


dbmopen

dbmopen -- opens a dbm database

Description

int dbmopen(string filename, string flags);

The first argument is the full-path filename of the dbm file to be opened and the second is the file open mode which is one of "r", "n", "c" or "w" for read-only, new (implies read-write, and most likely will truncate an already-existing database of the same name), create (implies read-write, and will not truncate an already-existing database of the same name) and read-write respectively.

Returns an identifer to be passed to the other dbm functions on success, or false on failure.

If ndbm support is used, ndbm will actually create filename.dir and filename.pag files. gdbm only uses one file, as does the internal flat-file support, and Berkeley db creates a filename.db file. Note that PHP does its own file locking in addition to any file locking that may be done by the dbm library itself. PHP does not delete the .lck files it creates. It uses these files simply as fixed inodes on which to do the file locking. For more information on dbm files, see your Unix man pages, or obtain GNU's gdbm from ftp://prep.ai.mit.edu/pub/gnu.


User Contributed Notes: dbmopen


jim@jaguNET.com
30-Apr-1999 05:14
dbmopen() also supports the 'c' mode, which is like the 'n' mode except the file is not truncated. Using 'c' mode makes DBM files "operate" just like Perl handles them


admin@cinenet.com.mx
28-Jul-1999 03:52
Most of the dbm functions can use the full-path of the dbm file as the argument instead of the db identifier generated by dbmopen() in a similar way it used to be on php2. The big exception is dbmclose() that MUST use the db identifier, otherwise the dbm file keeps open. Be aware of that if you're updating your php2 files.<br> i.e. this code works in the most lines, except to close the dbm file<br>
$fn="/full/path/of/dbmfile";
dbmopen($fn,"r");
$row=dbmfetch($fn,"MyKey");
dbmclose($fn);
Instead, allways prefer to use:<br>
$fn="/full/path/of/dbmfile";
$db=dbmopen($fn,"r");
$row=dbmfetch($db,"MyKey");
dbmclose($db);



skipatrol@sprintmail.com
13-Oct-1999 08:35
If using php3 on a win 95/98 machine, you must have the complete path to the db file. And always remember that if you user the " mark, add one extra slash before any regular slashes. Otherwise use the ' and normal slashes. ex.
$dmb = 'd:\httpd\storit\users';

$modify = dbmopen($dmb, "w");
$username = dbmfetch($modify, $email, $username);
$password = dbmfetch($modify, $username, $password);

echo "Current username: $username";
echo "Current password: $password";

exit;




achim@nasa20.com
11-Jan-2000 07:11
i tried to open a file, created with dbmmanage (part of apache). i used the following code: $db_file = "/path/file.db"; $db = $dbmopen($db_file, "r"); this happens: bmopen_gdbm(/www/develop.nasa20.com/htdocs/achim/htpass.db): 7 [Bad magic number], 0 [Success] in what went wrong??


 About Notes


Previous page
 DBM
dbmclose 
Next page



Site Statistics


Who's responsible for this?
Top of this page

Site
Hosting:



Located in
United States
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.