Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
PHP: dbmopen - Manual
[go: Go Back, main page]

PHP  
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
search for in the  
<dbmnextkeydbmreplace" width="11" height="7"/>
view the version of this page
Last updated: Sat, 06 May 2006

dbmopen

(PHP 3, PHP 4, PECL)

dbmopen -- DBM データベースをオープンする

説明

resource dbmopen ( string filename, string flags )

第 1 引数はオープンされる DBM ファイルのフルパス名で、第 2 引数は ファイルオープンモードです。これは "r", "n", "c", "w" のうちのいずれかで、 順に読み込み用、新規ファイル(読み書き可能。既に存在する同名のファイルを 上書きする可能性があります)、作成(読み書き可能。既に存在する同名の ファイルを上書きしません)および読み書き用を示します。

成功した場合は他の DBM 関数に渡す ID、失敗した場合は FALSE を返します。

NDBM サポートが有効な場合、実際に NDBM が filename.dirfilename.pag ファイルを作成します。GDBM は、 PHP 組み込みのフラット・ファイル機能と同様に 1 つのファイルしか 使いません。Berkeley DB は、filename.db ファイルを作成します。 PHP では、DBM ライブラリ自体が行うファイルロックに加えて 自分自身でもファイルロックを行うということに注意してください。 PHP では自分で生成した .lck ファイルを 削除しません。PHP では単純にこれらの ファイルをファイルロックのための固定 inode として使用します。 DBM ファイルに関する詳細情報は、Unix の man ページを参照するか、 GNU の GDBM を取得してください。

注意: セーフモード が有効の場合、PHP は操作を行うファイル/ディレクトリが実行するスクリプトと 同じ UID (所有者)を有しているかどうかを確認します。



add a note add a note User Contributed Notes
dbmopen
sitz at onastick dot net
17-Jul-2001 05:11
Want to use dbmopen() to open an NDBM DB under solaris? Want to have GDBM support as well? Tough; you can't. You *can* use dba_open(), but you need to jump through a couple of hoops first:

First, you need to re-roll libgdbm so that DBM/NDBM compatiblity are removed. For GDBM-1.7.3, change this line in the Makefile:

OBJS = $(DBM_OF) $(NDBM_OF) $(GDBM_OF)

to this:

OBJS = $(GDBM_OF)

Once that's installed, re-run ./configure --with-gdbm=/<prefix> --with-ndbm --with-db=/<prefix> <other args>, where <prefix> is the directory which holds the include/ directory containing the associated header files. make, make install, adjust your scripts to use dba_open() with the ndbm handler. Voila!
donotspam-dbirchall at cheaptickets dot com
07-Jul-2001 12:20
Like the last few posters, I noticed dbmopen() suddenly stop working when I went from PHP3 to PHP4.  Fortunately, I (unlike them? ;) noticed mavetju's post suggesting rebuilding PHP with --with-db and --with-ndb.  Unsurprisingly, this solved it.  Many thanks to mavetju, and I encourage other users to read answers that have already been posted. :)
mavetju at chello dot nl
11-Jan-2001 11:19
If you are running php >4.0.2 and you have suddenly problems with dbmopen (i.e. it complains that the function does not exist), recompile php with --with-ndb *and* --with-db
skipatrol at sprintmail dot com
14-Oct-1999 12: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.

$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;
admin at cinenet dot com dot mx
28-Jul-1999 07: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.
i.e. this code works in the most lines, except to close the dbm file:

$fn="/full/path/of/dbmfile";
dbmopen($fn,"r");
$row=dbmfetch($fn,"MyKey");
dbmclose($fn);

Instead, allways prefer to use:

$fn="/full/path/of/dbmfile";
$db=dbmopen($fn,"r");
$row=dbmfetch($db,"MyKey");
dbmclose($db);

<dbmnextkeydbmreplace" width="11" height="7"/>
 Last updated: Sat, 06 May 2006
show source | credits | sitemap | contact | advertising | mirror sites 
Copyright © 2001-2006 The PHP Group
All rights reserved.
This mirror generously provided by: PacketBusiness, Inc.
Last updated: Sun Sep 3 14:25:38 2006 JST