Currently I'm using Eclipse PHP IDE and try to using PDO MySQL on this IDE. The code that I'm gonna try is the PDO constructor:
$dsn = 'mysql:dbname=db_pdo;host=localhost';
$user = 'imbagila';
$password = 'mypass';
try {
$dbh = new PDO($dsn, $user, $password);
} catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}
After that, I'm gonna run that code on PHP CLI Application in IDE. But then it's return the error like this :
PHP Fatal error: Uncaught Error: Class 'PDO' not found in
/home/imbagila/Documents/php/eclipse/myproject/index.php:8 Stack trace:
#0 {main} thrown in /home/imbagila/Documents/php/eclipse/myproject/index.php on line 8
But when I tried at terminal (also CLI, by typing php index.php
) it's return nothing, which mean it's successfully executed with no errors. Why this happens ? Can someone give the solutions so I can use PDO MySQL on my Eclipse IDE ?
- OS : Xubuntu 18.04
- PHP Version : 7.2
- Eclipse PHP IDE Version : Photon Release (4.8.0)
- Eclipse Run Configuration :
- Runtime PHP : Installed PHP (7.2)
- Executable path : /usr/bin/php7.2
- PHP ini file : /etc/php/7.2/cli/php.ini
- SAPI : CLI Version 7.2.7