ADOdb – database abstraction library for PHP

ADOdb is what really saved my life when moving from Classic ASP to PHP5, it supports a wide variety of database, and has some great functionality features. It supports PHP5 aswell :)
You can find ADOdb here: http://adodb.sourceforge.net/

Here are some examples of your daily database connect and retrieval:

include('/path/to/adodb.inc.php');
$DB = NewADOConnection('mysql');
$DB->Connect($server, $user, $pwd, $db);

# M'soft style data retrieval with binds
$rs = $DB->Execute("select * from table where key=?",array($key));
while (!$rs->EOF) {
print_r($rs->fields);
$rs->MoveNext();
}

# PEAR style data retrieval
$rs = $DB->Execute("select * from table where key=123");
while ($array = $rs->FetchRow()) {
print_r($array);
}

# Alternative URI connection syntax:
$DB = NewADOConnection("mysql://$user:$pwd@$server/$db?persist");

# No need for Connect or PConnect when using URI syntax

$ok = $DB->Execute("update atable set aval = 0");
if (!$ok) mylogerr($DB->ErrorMsg());

Here is some more cool things you could do with ADOdb:

# Updating tables
$ok = $DB->Execute("update table set col1=? where key=?",array($colval, $key));

# retrieving data shortcuts
$val = $DB->GetOne("select col from table where key='John'");
$row = $DB->GetRow("select col from table where key='John'");
$arr = $DB->GetAll("select col from table");
$arr = $DB->GetAssoc("select key,col from table"); # returns associative array $key=>col

# Retrieve high speed cached recordsets (cached for 3600 secs)
# Cache directory defined in  global $ADODB_CACHE_DIR.
# CacheGetOne, CacheRow, CacheGetAll all work
$rs = $DB->CacheExecute(3600, "select orgname from users where user='JOHN'");
Comments: 1 Comment.
Comments
Comment from Jared Kim - January 11, 2006 at 04:11

I just switched over to ADODB from my own abstraction library. It’s amazing and I love the query caching feature, especially since MySQL’s own query caching doesn’t work.