ADOdbPHP的数据库接口
ADOdb 是一个 PHP 编程语言用来访问数据库的抽象接口。
示例代码:
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());
评论