DBM Compatibility layer

From: Date: Thu, 18 Apr 2002 18:00:22 +0000
Subject: DBM Compatibility layer
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-5647@lists.php.net to get a copy of this message
Hi Folks, While I don't have it completely up to PEAR standards yet, I would like your opinions on a DBM compatibility layer for PEAR. What I'm proposing is something to go between the dbm functions in PEAR and an application to smooth out inconsistencies between DBM implementations, sort of like DB does for SQL databases but more like the anydbm module in Python http://www.python.org/doc/current/lib/module-anydbm.html I have implemented the function equivalent of Python's dumbdbm for handling the case where no DBM libraries are present in a PHP install (the common case for me, sadly.) It is located here: http://ozma.union.utexas.edu/~busterb/SimpleDBM.tar.gz It provides a class called SimpleDBM which provides the actual functionality and a set of equivalent functions to mirror PHP's own dbm functions. The class implements a heap-type database with a linear index, and stores its data in two files, name.dat and name.idx. To open a database, it only has to read an index file, rather than an entire database (a slight advantage over CSV files;) It also supports multiple concurrent readers/writers, and there are some example files to test this. One big improvement I am working on is usage of the File class for handling files. Currently, it uses a lot of logic just to determine what types of file locks to use. Also, when soft updates are enabled (just a fancy term saying that the database index isn't written until the database is closed), if a database is written to but not closed, corruption can occur. I'm contemplating using File's append mode to tack on 'transactions' to the index, and then recovering from a missing close. Let me know if you think this would be a useful addition to PEAR. I'm using it right now as the basis for a slightly more useful database system that supports actual selects, joins and the like. - Brent

« previous php.pear.dev (#5647) next »