looking for a db abstraction/substitute that actually works
i am looking for a form of data storage that will answer a few requirements. i realize these requirements are non-standard, and for now i'm using activerecord and ORM solutions like everyone else, but this is my "holy grail" - if you know of anything like this, i would be eternally grateful:
- pure PHP
- multiple repositories, preferably file based for portability, where i can instantiate by telling it "use repository [X]" - i don't want to pre-create repository [X], if i reference it, it exists.
- zero database configuration - i don't want to create tables or export SQL dumps, if it's referenced in my code, it needs to be in the database, auto-created without any fuss, my code is my schema
- hierarchical, not relational, ideal structure would be just a freeform, schema-less XML, but since XML performs horribly with large trees, it can't simply be an XML file.
i have experimented with flat XML storage (with xpath and xquery) but it gags on a mid-sized repository, and cripples the application.
i have also experimented with key=>value pairs dropped into a SQLite database with a single generic table, but that gags even faster, and re-forming even the simplest record from key=>value pairs is a performance decimator.
finally, i experimented with lucene as implemented in the zend framework, which was pretty close to ideal, apart from the no-update part.
any ideas, anyone?
I've been having great fun with RedBean, it's not quite designed for flatfiles, but runs on PDO, so it should be relatively easy to write a sqlite module for it. Not sure if it will work for your needs, but definitely worth taking a look at.
Here are some links you may find useful:
Also, have you considered using Berkeley DB?
Some of the DB extensions listed in the PHP Manual are intended to be used on flat-file like databases.
From your description it seems like PHP arrays should work perfectly:
- pure PHP
- multiple arrays, file or memory based
- your code is your schema
You could use serialize() or var_export() functions to enable file storage.