我想通过PHP命令行使用PDO。 它通过PHP Web API完美运行,但不是通过命令行。
但是当我执行命令: php test.php 时,它会显示未知的类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
如果问题出在模块上,我在哪里可以获得这些模块的线程安全模块?
答案 0 :(得分:1)
您的PHP和您的模块使用不同的线程安全性进行编译(在PHP中“打开”,在模块中“关闭”)。获取PHP的the correct non-thread-safe(或“nts”)版本以匹配您尝试使用的模块,并解决您的问题。
答案 1 :(得分:1)
啊,你明白了 使用模块API = 20060613,debug = 0, thread-safety = 0 编译的模块 用模块API编译的PHP = 20060613,debug = 0, thread-safety = 1
线程安全不匹配。你需要打开线程安全的那些。
答案 2 :(得分:0)
您在php.ini中定义extension_dir时出错。试着把绝对路径放在那里。