php教程 連接access數(shù)據(jù)庫教程代碼
下面提供三種php連接access數(shù)據(jù)庫方法,一種是利用php的pdo,一種是odbc,com接口來與access數(shù)據(jù)庫連接哦。
*/
//利用pdo與access數(shù)據(jù)庫連接
$path ="f:fontwww.111cn.netspiderresult.mdb";
$conn = new pdo("sqlite:$path");
if( $conn )
{
echo ('connection pdo success');
}
else
{
echo ('cnnection pdo fail ,plase check database server!');
}
//利用 odbc_connect連接數(shù)據(jù)庫
$conn = odbc_connect("dbdsn","admin","123"); //連接數(shù)據(jù)源
$doquery=odbc_exec($conn,"select * from 表名 where 條件");//執(zhí)行查詢 //利用com接口連接access數(shù)據(jù)庫
$conn=new com("adodb.connection");
$dsn="driver={microsoft access driver (*.mdb)};dbq=".realpath("path/db1.mdb");
$conn->open($dsn);
更多信息請查看IT技術(shù)專欄