Home > Backend Development > PHP Tutorial > 三种php连接access数据库方法_php实例

三种php连接access数据库方法_php实例

WBOY
Release: 2016-06-07 17:23:04
Original
972 people have browsed it

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

复制代码 代码如下:

$path ="f:fontwww.php.netspiderresult.mdb";
 $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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template