如何让PHP命令行与PDO一起工作?

如何让PHP命令行与PDO一起工作?,php,command-line,pdo,Php,Command Line,Pdo,我想通过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=200606

我想通过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
  • PHP版本:5.2.9-2,下载自 .
  • 操作系统:Windows Vista

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

在php.ini中定义扩展名\u dir时出错。尝试将绝对路径放在那里。

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

啊,您看到了吗 使用模块API=20060613、调试=0、线程安全性=0编译的模块 PHP编译时使用模块API=20060613,调试=0,线程安全性=1


线程安全性不匹配。您需要启用线程安全设置。

否。这是一条绝对的道路。extension_dir=“C:/php5.2.9/ext”