PHP连接access数据库
程序员文章站
2022-05-12 12:54:20
复制代码 代码如下:
<?php
/*
创建ado连接
*/
$conn = @new com("adodb.connection") or die ("ado connection faild.");
$connstr = "driver={microsoft access driver (*.mdb)}; dbq=" . realpath("datum/cnbt.mdb");
$conn->open($connstr);
/*
创建记录集查询
*/
$rs = @new com("adodb.recordset");
$rs->open("select * from dbo_dirs",$conn,1,3);
/*
循环读取数据
*/
while(!$rs->eof){
echo "$rs->fields["title"]->value;
echo "<br/>";
$rs->movenext(); //将记录集指针下移
}
$rs->close();
?>
复制代码 代码如下:
<?php
/*
创建ado连接
*/
$conn = @new com("adodb.connection") or die ("ado connection faild.");
$connstr = "driver={microsoft access driver (*.mdb)}; dbq=" . realpath("datum/cnbt.mdb");
$conn->open($connstr);
/*
创建记录集查询
*/
$rs = @new com("adodb.recordset");
$rs->open("select * from dbo_dirs",$conn,1,3);
/*
循环读取数据
*/
while(!$rs->eof){
echo "$rs->fields["title"]->value;
echo "<br/>";
$rs->movenext(); //将记录集指针下移
}
$rs->close();
?>
下一篇: 发现客户潜在需求