views:

41

answers:

2

I have to access and write to some berkeley db files that other applications share.

I really haven't found anything out there about using this with PHP. It really doesn't seem very popular.

Does anyone have any links or resources that I might be able to use to get things rolling?

Thanks!

A: 

Berkley DB isn't really meant for multi-user access. It is much better for an embedded database that is accessed by one process.

PHP processes run asyncronously on the web site. This means a php script accessing a Berkley DB has to rely on file locking to handle concurrent access.

This is very inefficient. thus no BDB support in php.

If you want to use BDB in a multi-user environment, you should write a web service in perl/c/python/etc that talks to BDB, and accepts connections from php. Or you could just use a real db server like mysql, postgres or something and save yourself the headache.

Byron Whitlock
How does moving the BDB access to a web service fix the concurrent access problem?
Craig
@Craig Good point, it doesn't. He could implement implement locking in PHP as well.
Artefacto
Hmm, I'll stand corrected for now. I've deleted my posts until I run a few more tests. Preliminary tests seem to agree with your post.
Dragontamer5788
+1  A: 

Isn't this what the dba functions are for?
http://php.net/manual/en/book.dba.php

I've had some code some years ago with that. Didn't use it much however, because it was a somewhat inefficient data store. And it seems kind of pointless in the light of SQLite now anyway. But btw: http://schlueters.de/blog/archives/134-Berkeley-DB-5-and-PHP.html

mario
Thanks for the info. I was able to get things working using the DBA abstraction layer.
Failpunk