Hi,
I have been using Creole for a year, but Creole project is dead now..
what are other good abstractions for php ?
Hi,
I have been using Creole for a year, but Creole project is dead now..
what are other good abstractions for php ?
I think the built-in PDO library might be what you're looking for.
The PDO Abstraction Layer is compiled by default in to versions of PHP >= 5.1
Beware, however, that PDO is not for systems where performance is the top goal. PDO is for situations where compatibility is the foremost concern.
"PDO is not for use on systems where mysql performance is a top goal" => http://dealnews.com/developers/php-mysql.html
If you are just using mysql, then you had better use the php_mysqli extension.
Why don't you give ADODB a shot? It's pretty much an active project and supports an amazing number of databases:
It's got very simple syntax and the learning curve is quite low. Here's a small example from their site:
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());
Cheers, miCRoSCoPiC^eaRthLinG
You could always write your own. A singleton database handler should only be about 500 lines, including comments.
I used EZ SQL in the past, which really speeds up writing PHP/MySQL apps.
It is the SQL library used in Wordpress.
Will
For PHP 5, have a look http://www.openmv.com/ (MV_Database_Connection), it's new but has a very portable and consistent well-tested api.
Very similar to ADODB but much cleaner code.
give a try to DALMP: http://code.google.com/p/dalmp/ is support prepared statements and many cache backends, besides being very fast