PDO:如何在Linux上访问Microsoft Access文件? [英] PDO: How to access Microsoft Access file on Linux?
本文介绍了PDO:如何在Linux上访问Microsoft Access文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经设法在Windows上使用PDO读取Microsoft Access文件(.accdb)的数据,但是在Linux(CentOS)上无法正常工作.我可以看到模块已安装:
I have managed to read data of Microsoft Access file (.accdb) on Windows using PDO but I'm having problem getting to work on Linux (CentOS). I can see modules is installed:
[root@rapid host]# php -m | grep PDO
PDO
PDO_ODBC
[root@rapid host]# php -m | grep odbc
odbc
代码:
<?php
try{
$dbhAccess = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=/root/access/data.accdb;Uid=Admin");
}
catch(PDOException $e){
echo $e->getMessage();
exit();
}
执行(CLI)PHP文件时出现错误:
I get an erro when I execute (CLI) PHP file:
[root@rapid host]# php access.php
SQLSTATE[IM002] SQLDriverConnect: 0 [unixODBC][Driver Manager]Data source name not found, and no default driver specified
推荐答案
您应该安装MDB驱动程序.
you should install the MDB driver.
我现在无法尝试,但是我认为 MDB工具(特别是 ODBC驱动程序)可以完成您感兴趣的事情.
I have no way to try it now, but I think that MDB Tools (specifically the ODBC driver) can do what you' re interested to.
这篇关于PDO:如何在Linux上访问Microsoft Access文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文