Home  >  Article  >  Backend Development  >  PHP使用PDO连接Access的方法_PHP教程

PHP使用PDO连接Access的方法_PHP教程

WBOY
WBOYOriginal
2016-07-20 11:17:511262browse

  try{

  $db = new PDO("odbc:driver={microsoft access driver (*.mdb)};dbq=".getcwd()."#db.mdb");

  echo "Connectedn";

  } catch (Exception $e) {

  echo "Failed:".$e->getMessage();

  }

  连接成功!如果没有,请确认PDO扩展已安装,打开php.ini,查看有没有这么一句:extension=php_pdo_odbc.dll

  没有的话自行添加,可以调用phpinfo()查看扩展有没有正确的安装!

  如果有图中红色框内的就是正确安装了。

  这里有个小小的注意,字符串“(*.mdb)”的前面必须有一个空格,

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/371878.htmlTechArticletry{ $db = new PDO(odbc:driver={microsoft access driver (*.mdb)};dbq=.getcwd().#db.mdb); echo Connectedn; } catch (Exception $e) { echo Failed:.$e-getMessage(); } 连接成功!如果...
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