Home > php教程 > php手册 > 三种php连接access数据库方法

三种php连接access数据库方法

WBOY
Release: 2016-06-06 20:26:33
Original
1978 people have browsed it

本文提供三种php连接access数据库的方法

一种是利用php的pdo,一种是odbc,com接口来与access数据库连接。
利用pdo与access数据库连接
 

复制代码 代码如下:


$path ="f:font";
 $conn = new pdo("sqlite:$path");
 if( $conn )
 {
  echo ('connection pdo success');
 }
 else
 {
  echo ('cnnection pdo fail ,plase check database server!');
 }


 利用 odbc_connect连接数据库
 

复制代码 代码如下:


 $conn = odbc_connect("dbdsn","admin","123"); //连接数据源
 $doquery=odbc_exec($conn,"select * from 表名 where 条件");//执行查询

 


利用com接口连接access数据库
$conn=new com("adodb.connection");
 $dsn="driver={microsoft access driver (*.mdb)};dbq=".realpath("path/db1.mdb");
 $conn->open($dsn);
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template