【问题标题】:How to get PHP command line to work with PDO?如何让 PHP 命令行与 PDO 一起工作?
【发布时间】:2009-09-21 12:51:39
【问题描述】:

我想通过 PHP 命令行使用 PDO。 它可以通过 PHP Web API 完美运行,但不能通过命令行运行。

但是当我执行命令时:php test.php,它说unknown class PDO。

我认为这与线程安全差异有关。 因为,当我执行上述命令时,会出现以下警告:-

F:\shema\htdocs>php test.php
PHP Warning:  PHP Startup: soap: Unable to initialize module
Module compiled with module API=20060613, debug=0, thread-safety=0
PHP    compiled with module API=20060613, debug=0, thread-safety=1
These options need to match
 in Unknown on line 0
PHP Warning:  PHP Startup: sockets: Unable to initialize module
Module compiled with module API=20060613, debug=0, thread-safety=0
PHP    compiled with module API=20060613, debug=0, thread-safety=1
These options need to match
 in Unknown on line 0
PHP Warning:  PHP Startup: mysql: Unable to initialize module
Module compiled with module API=20060613, debug=0, thread-safety=0
PHP    compiled with module API=20060613, debug=0, thread-safety=1
These options need to match
 in Unknown on line 0
PHP Warning:  PHP Startup: pdo_mysql: Unable to initialize module
Module compiled with module API=20060613, debug=0, thread-safety=0
PHP    compiled with module API=20060613, debug=0, thread-safety=1
These options need to match
 in Unknown on line 0
PHP Warning:  PHP Startup: pdo_pgsql: Unable to initialize module
Module compiled with module API=20060613, debug=0, thread-safety=0
PHP    compiled with module API=20060613, debug=0, thread-safety=1
These options need to match
 in Unknown on line 0
PHP Fatal error:  Class 'PDO' not found in F:\shema\htdocs\test.php on line 2
  • PHP版本:5.2.9-2,下载自 here
  • 操作系统:Windows Vista

如果问题出在模块上,我从哪里获得这些模块的线程安全模块?

【问题讨论】:

    标签: php command-line pdo


    【解决方案1】:

    您的 PHP 和您的模块是使用不同的线程安全编译的(在 PHP 中“打开”,在模块中“关闭”)。获取the correct non-thread-safe(或“nts”)构建的 PHP 以匹配您尝试使用的模块,您的问题应该会解决。

    【讨论】:

      【解决方案2】:

      啊,你看 使用模块 API=20060613、debug=0、thread-safety=0 编译的模块 PHP 编译模块 API=20060613, debug=0, thread-safety=1

      线程安全不匹配。你需要得到那些开启了线程安全的。

      【讨论】:

        【解决方案3】:

        您在 php.ini 中定义 extension_dir 时出错。尝试把绝对路径放在那里。

        【讨论】:

        • 不。这是绝对路径。 extension_dir = "C:/php5.2.9/ext"
        猜你喜欢
        • 2014-10-17
        • 1970-01-01
        • 2017-06-25
        • 1970-01-01
        • 2015-04-10
        • 2010-09-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多