Three ways to connect to the Access database in PHP _php tutorial

Source: Internet
Author: User
Tags dsn
One is the use of PHP PDO, a odbc,com interface to connect to an Access database.
Using PDO to connect to an Access database
Copy CodeThe 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! ');
}

Connecting Databases with Odbc_connect
Copy CodeThe code is as follows:
$conn = Odbc_connect ("Dbdsn", "admin", "123"); Connecting to a data source
$doquery =odbc_exec ($conn, "select * from table name where Condition");//Execute Query


Connect to an Access database by using COM interfaces
$conn =new com ("adodb.connection");
$DSN = "Driver={microsoft Access Driver (*.mdb)};d bq=". Realpath ("Path/db1.mdb");
$conn->open ($DSN);

http://www.bkjia.com/PHPjc/825153.html www.bkjia.com true http://www.bkjia.com/PHPjc/825153.html techarticle One is the use of PHP PDO, a odbc,com interface to connect to an Access database. Use PDO to connect to the Access database to copy the code code as follows: $path = "F:fontwww.jb51.netspiderresult ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.