Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get PHP command line to work with PDO?

I want to work with PDO, through PHP command line. It works perfect through the PHP web API, but not through the command line.

But when I execute the command: php test.php, it says unknown class PDO.

I think it has something to do with the thread-safety difference. Because, when I execute the above command, the following warnings come: -

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 version: 5.2.9-2, downloaded from here.
  • OS: Windows Vista

If the problem is with the modules, where do I get the thread safe modules for those modules?

like image 422
Sabya Avatar asked Jan 01 '26 16:01

Sabya


2 Answers

Your PHP and your modules were compiled with different thread-safety (turned "on" in PHP, turned "off" in the modules). Grab the correct non-thread-safe (or "nts") build of PHP to match the modules you're trying to use and your problem should clear up.

like image 132
TML Avatar answered Jan 03 '26 04:01

TML


Ah, you see Module compiled with module API=20060613, debug=0, thread-safety=0 PHP compiled with module API=20060613, debug=0, thread-safety=1

Thread safety mismatch. You need to get the ones with thread safety turned on.

like image 43
Vladislav Rastrusny Avatar answered Jan 03 '26 06:01

Vladislav Rastrusny



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!