PHP PDO 扩展在命令行中不可用
我已从 WAMP 迁移到 EasyPHP,现在使用 PDO 时出现问题。 当我在浏览器中查看站点时,PDO 工作正常,但在 cmd 中或通过 Netbeans 运行测试文件时不起作用。 我得到:
“PDOException:找不到驱动程序”
在配置命令的 phpinfo()
中我
cscript /nologo configure.js " --enable-snapshot-build" " --disable-isapi" " --enable-debug-pack" " --disable-isapi" " --without-mssql" " --without-pdo-mssql" " --without-pi3web" " --with-pdo-oci=D:\php-sdk\oracle\instantclient10\sdk, shared" " --with-oci8=D:\php-sdk\oracle\instantclient10\sdk, shared" " --with-oci8-11g=D:\php-sdk\oracle\instantclient11\sdk, shared" " --enable-object-out-dir=../obj/" " --enable-com-dotnet" " --with-mcrypt=static" " --disable-static-analyze"
在 php.ini
中我已经取消注释这些行:
extension=php_pdo_mysql.dll
extension=php_mysql.dll
关于如何获得此内容的任何想法在职的?
I've moved from WAMP to EasyPHP and now there are problems using PDO.
PDO works fine when I view the site in the browser, but doesn't work in cmd or when I run the test file via Netbeans.
I get:
"PDOException: could not find driver"
In phpinfo()
for Configure Command I have
cscript /nologo configure.js " --enable-snapshot-build" " --disable-isapi" " --enable-debug-pack" " --disable-isapi" " --without-mssql" " --without-pdo-mssql" " --without-pi3web" " --with-pdo-oci=D:\php-sdk\oracle\instantclient10\sdk, shared" " --with-oci8=D:\php-sdk\oracle\instantclient10\sdk, shared" " --with-oci8-11g=D:\php-sdk\oracle\instantclient11\sdk, shared" " --enable-object-out-dir=../obj/" " --enable-com-dotnet" " --with-mcrypt=static" " --disable-static-analyze"
In php.ini
I have already uncommented these lines:
extension=php_pdo_mysql.dll
extension=php_mysql.dll
Any ideas on how I can get this working?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
从命令行运行 php 时,可以使用
-c
或--php-ini
参数指向php.ini
文件使用。这将允许您对两者使用一个 php.ini 文件。如果您自己运行脚本,您还可以将php
别名为php -c/path/to/php.ini
。When running php from the command line, you can use the
-c
or--php-ini
argument to point to thephp.ini
file to use. This will allow you to use one php.ini file for both. You can also aliasphp
tophp -c/path/to/php.ini
if you are running the script yourself.如果您在 Linux 或 Windows 中安装所有 Web 服务器,通常会使用 2 个不同的 php.ini。一种用于 CLI(命令行客户端),一种用于 APACHE 或无论服务器位于 easyphp 中。
我无法帮助你更多,因为我在 Linux 上并且不使用 EasyPHP,但是朝那个方向看,也许系统范围的搜索可以帮助你?
All web server install should you be in linux or windows usually use 2 different php.ini. One for the CLI (Command line client) and one for APACHE or wathever the server is in easyphp.
I can't help you more than that since i'm on linux and don't use EasyPHP, but look in that direction, maybe a system wide search can help you out?
我找到了问题的解决方案。正如 Mathieu Dumoulin 指出的那样,PHP 为 CLI 加载了不同的 .ini。所以我所做的就是在 php 文件夹下创建一个 php-cli.ini 文件,问题就解决了。
I found the solution to the problem. As Mathieu Dumoulin pointed out, PHP has loads a different .ini for CLI. So what I did was create a php-cli.ini file under php folder and the problem was solved.