如何将 ODBC 驱动程序添加到 MAMP 环境?
我正在开发使用 php 和 ms access 数据库在 PC 设置上构建的东西。 当我将应用程序移植到 MAMP 环境时,
Fatal error: Call to undefined function odbc_connect() in /path/to/index.php on line 37
第 37 行看起来像这样:
return odbc_connect("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=myfile.mdb",
"ADODB.Connection", "", "SQL_CUR_USE_ODBC");
看来 odbc 没有编译到 PHP 的 MAMP 版本中 (5)。 我也尝试过使用 PDO,并遇到类似的错误。
有人知道怎么修这个东西吗?
I'm working on something that was built on a PC set-up using php and an ms access database. When I port the app to my MAMP environment, I get
Fatal error: Call to undefined function odbc_connect() in /path/to/index.php on line 37
line 37 looks like this:
return odbc_connect("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=myfile.mdb",
"ADODB.Connection", "", "SQL_CUR_USE_ODBC");
It seems like odbc isn't compiled into the MAMP version of PHP (5). I also tried using PDO, and got similar errors.
Anyone know how to fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要向您的计算机添加一个 ODBC 驱动程序,例如 Actual ODBC,也就是说,如果您的 PHP 版本有任何 ODBC 功能都符合,它应该具有,但如果没有,您将需要安装具有适当支持的不同版本。 我很幸运地使用 MacPorts 安装 PHP。 但请注意,仍然缺少一些函数,您可能需要为这些函数编写包装器,如下所示:
You will need to add an ODBC driver like Actual ODBC to your machine, that is if your version of PHP had any ODBC functionality complied in, which it should have, but if not you'll need to install a different version with the appropriate support. I've had good luck with using MacPorts to install PHP. But note that there are still some functions missing that you may expect you'll have to write wrappers for these functions like so: