php dba_open,dba_open - [ php中文手册 ] - 在线原生手册 - php中文网

用户评论:

[#1]

dracoirs at gmail dot com [2010-05-03 15:10:43]

Apache doesn't support Berkeley DB Btree, so you can't manipulate use db4 as the type of database if you want to do DBM authentication with Apache.

gdbm seemed to work fine though, even though it supposedly using Btree instead of hash.  It makes you wonder why Apache would use hash for one dbmtype versus btree for another.

So since Apache and PHP don't have options to choose the method for the Berkeley DBs, you are out of luck.

[#2]

cbemerine at gmail dot com [2009-09-06 04:59:33]

Note the ??c?? create flag does not work if MySQL was built with the ??cdb?? DBA handler compile option which is common for many distros.  By definition the cdb DBA handler is optimized for reading/writing and ??no updates are allowed.??

$dbh=dba_open("./data2/productz","c","cdb") or die("Couldn't open Database");?>

instead use

$dbh=dba_open("./data2/productz","n","cdb") or die("Couldnt open Database");?>

generates this error message in the /var/log/apache2/error.log:

[Sun Sep 06 04:18:15 2009] [error] [client 192.168.1.125] PHP Warning:  dba_open(./data2/productz,c) [function.dba-open]: Driver initialization failed for handler: cdb: Update operations are not supported in /var/www/projects/testcdb-c.php on line 43

see user contributed comment under dba_handlers() to see which DBA handlers are supported by your build of MySQL and note about using ??cdb?? compiled DBA systems:

also see user contributed comment under dba_replace() about incompatibilities with cdb DBA handler compiled MySQL systems.

[#3]

mskala at ansuz dot sooke dot bc dot ca [2008-05-16 14:15:21]

As of GDBM version 1.8.3, GDBM's underlying open call uses non-blocking calls to flock() on systems that have flock().  As a result, calls with "rd" or "wd" locking modes will return error ("Can't be reader" or "Can't be writer") instead of waiting.  Use "rl" or "wl" instead, to make PHP do its own locking external to GDBM.

[#4]

trohit at blue bottle dot com [2007-11-23 03:34:42]

Here's a simple example to use the dba_open function

$id=dba_open("/tmp/test.db","n","gdbm");

if (!$id) {

echo"dba_open failed\n";

exit;

}dba_replace("key","This is an example!",$id);

if (dba_exists("key",$id)) {

echodba_fetch("key",$id);dba_delete("key",$id);

}dba_close($id);?>

[#5]

doppelbauer at gmail dot com [2006-10-20 07:36:48]

Windows does not support locking the database. You may use $_ENV to determine the OS:

$locking = (stripos($_ENV['OS'],'windows') === false ? 'd' : 'l');

[#6]

xy ?t affenkrieger.de [2006-03-30 06:13:26]

If you get some strange errors like

dba_open(): myDbFilename.db : Permission denied

than you are propably using PHP on a Windoze machine. You have to make sure that the following conditions are met:

1) Use an absolute path to your db file. Relative paths will cause problems with locking

2) Specify a locking mode - that's the second character of the mode-argument, or else opening a dba-file will cause several notices/warnings etc.

And a final, general note:

3) Always use the english PHP doc on this site - the translations are often old as hell and miss important informations

HTH, Nils.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值