views:

147

answers:

2

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:

  1. pure PHP
  2. 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.
  3. 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
  4. 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?

A: 

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.

Fauxide
really cool project, thanks. i think i can use it in my project, maybe take a day or so to write a SQLite connector, but even without SQLite, it's just great.
Nir Gavish
+1  A: 

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
  • hierarchical

You could use serialize() or var_export() functions to enable file storage.

Alix Axel
i am familiar with both txtSQL and gladius, but i may as well use SQLite. my question was about a persistent data store with behaviour **different** from a normal relational database.Berkeley DB (or rather, Berkeley DB XML) looks promising, but it requires **purchase** and **installation**, which makes it unusable to me.
Nir Gavish
@Nir: Answer updated, maybe you should try to describe what you're after in more detail.
Alix Axel
Arrays work up to a point, the problem begins when you have massive amounts of data you need to index/search/sort. My ideal solution would be something like one or more of these: 1) an XML file i can do what i want with, without the performance issues of XML. 2) a database i can throw objects into while following no schema or predefined structure, and then be able to run queries on all objects as if they were all in the same table 3) redBean is not perfect, but looks super cool, if it supported SQLite, i would probably say "problem solved, I can make this work"
Nir Gavish