At work we have a somewhat handy database class. It was written as commercial code, so I wouldn't feel right using it in free apps. So I wrote my own (improved, I'd say
version of it.
Basically, it keeps an associative array representing the database, allowing you to load, save, and create an entry extremely easily.
I wrote the database class, a settings file, and a demo file. The demo file shows how to load, update, and insert entries, as well as how to query a list and count entries in a table and a few other things.
This probably shouldn't be used directly from your normal display code. I'd write a middle-layer that generates queries and plays with objects, basically implementing the business layer, then a fairly simple display layer, or something. But that's just me.
<edit> Also, it should be secure against SQL-Injection and XSS except where I specifically say it isn't. The get() and set() functions definitely won't fall victim to SQL-Injection or XSS, and the only places that will I think are the $where parameters for queries, which is pretty obvious.
Here is the source:
http://www.javaop.com/~ron/code/clsDB.tgzOr, if you just want to look:
http://www.javaop.com/~ron/code/clsDBAny comments or suggestions are welcome. I'm not actively using this code yet, so suggestions now or soon would be most helpful.
(a note about where I posted: this sort of fits in web-dev and in tutorials/examples.... I personally like having it in the 'examples', but if anybody thinks it belongs in webdev, you have my permission to move it)