首页 > PHP资讯 > PHP培训技术 > PHP的数据库接口 ADOdb

PHP的数据库接口 ADOdb

PHP培训技术

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());
本文由欣才IT学院整理发布,未经许可,禁止转载。