Database Abstraction

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Database Abstraction

Post by onion2k »

What database abstraction library, if any, do you use? I'm after a fairly simple one but with a handful of specific requirements:

1. It's got to work in PHP 4. PHP 5 as well would be nice but it's not vital.
2. It's got to work *everywhere*. That means it can't rely on PEAR being available (hence no PearDB or MDB).
3. It only needs to work with MySQL really.
4. It needs to handle a few things:
a. Escaping data.
b. Monitoring connections (a simple count of queries would be enough).
c. Returning data in the same form as PHP (eg, array, assoc or object).

I can't find anything good and I'm on the verge of writing my own, but I thought I'd ask first.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

ADOdb and PJ's ADOdb Lite are used by many, I believe.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

I use a very simple one like you do, and similar to the Connection classes that often pop-up around here. I tend to not do to much fancy database-wise out of habit. For example, I have more and more tended to push things like HTML into files rather than storing it in a database. If I am not querying the data -- just selecting by key -- then I think what the real use case is.
(#10850)
User avatar
AKA Panama Jack
Forum Regular
Posts: 878
Joined: Mon Nov 14, 2005 4:21 pm

Post by AKA Panama Jack »

My ADOdb Lite does all of what you ask. Check the link in my signature. :)

Plus, it even has a nifty debug console. :D

http://adodblite.sourceforge.net/debugconsole.php

Image
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

I would recommend ADOdb Lite if you are looking for features. However any library is going to be an order of magnitude bigger and probably do multiple includes as well. I think mine is under 3k and does everything on your list except monitoring.
(#10850)
Post Reply