2009-09-21 33 views
3

我想通過PHP命令行使用PDO。 它通過PHP web API完美工作,但不通過命令行。如何讓PHP命令行與PDO一起使用?

但是當我執行命令: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,從 here下載。
  • 操作系統:Windows Vista

如果問題與模塊,我在哪裏獲得這些模塊的線程安全模塊的?

回答

1

您的PHP和您的模塊被編譯時使用了不同的線程安全性(在PHP中「打開」,在模塊中關閉)。抓住the correct non-thread-safe(或「nts」)構建PHP以匹配您嘗試使用的模塊,並解決您的問題。

0

在php.ini中定義extension_dir時出錯。嘗試把絕對路徑。

+0

沒有。這是絕對路徑。 extension_dir =「C:/php5.2.9/ext」 – Sabya

1

啊,你看 模塊與模塊API編譯= 20060613,調試= 0,線程安全= 0 PHP編譯模塊API = 20060613,調試= 0,線程安全= 1

線程安全不匹配。你需要打開線程安全的。

相關問題