Home > Backend Development > PHP Tutorial > Three PHP methods to connect to access database_PHP tutorial

Three PHP methods to connect to access database_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:25:13
Original
932 people have browsed it

One is to use php's pdo, and the other is to use odbc and com interfaces to connect to the access database.
Use pdo to connect to the access database

Copy the code The code is as follows:

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

Use odbc_connect to connect to the database
Copy code The code is as follows:

$conn = odbc_connect("dbdsn","admin","123"); //Connect to data source
$doquery=odbc_exec($conn,"select * from table name where condition");//Execute query


Use the com interface to connect to the access database
$conn=new com("adodb.connection");
$dsn="driver={microsoft access driver (*.mdb)} ;dbq=".realpath("path/db1.mdb");
$conn->open($dsn);

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/825153.htmlTechArticleOne is to use php's pdo, and the other is odbc, com interface to connect to the access database. Use pdo to connect to the access database. Copy the code. The code is as follows: $path ="f:fontwww.jb51.netspiderresult...
Related labels:
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template