Home  >  Article  >  Backend Development  >  How to connect to access database in php

How to connect to access database in php

WBOY
WBOYOriginal
2016-07-25 09:13:211294browse
Share an example of PHP code to connect to access database. There are many ways to connect PHP code to access. Master the usage of these methods through examples.
  1. */
  2. //Use pdo to connect to the access database
  3. $path ="f:fontbbs.it-home.orgspiderresult.mdb";
  4. $conn = new pdo("sqlite:$path");
  5. if( $conn )
  6. {
  7. echo ('connection pdo success');
  8. }
  9. else
  10. {
  11. echo ('cnnection pdo fail ,plase check database server!');
  12. }
  13. //Use odbc_connect to connect to the database
  14. $conn = odbc_connect("dbdsn","admin","123"); //Connect to the data source
  15. $doquery=odbc_exec( $conn,"select * from table name where condition");//Execute query
  16. //Use the com interface to connect to the access database
  17. $conn=new com("adodb.connection");
  18. $dsn="driver ={microsoft access driver (*.mdb)};dbq=".realpath("path/db1.mdb");
  19. $conn->open($dsn);
Copy code



access, database


Statement:
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