pdo is working fine with mysql but with pgsql its giving error \'PDOException\' with message \'could not find driver\'
I\'ve installed php5-pgsql
p
Make sure you've uncommented the line that tells php where the Postgres driver is (usually extension=pgsql.so
) in the main php.ini
file.
I had the same issue. First of all - check is it enabled in php.ini. Uncomment extension=php_pdo_pgsql...
than set up extension directory!!
extension_dir = "ext" ; for your case it could be other dir.
and do not forget to restart server after changing the config.
Copy libpq.dll from the PHP directory to Apache24\bin (or wherever your installation could be).
When you do not have postgresql installed on the same machine that is Apache and PHP; you have to install php-pgsql
and don't have to add extensions in php.ini
manually in Linux (in Windows yes), because redundancies are generated and this does not work (checked in error.log
).
$ sudo apt install php-pgsql
Then you can check the existence of the extension enabled automatically in:
$ sudo nano /etc/php/7.0/apache2/conf.d/10-pdo.ini
Observations: In phpinfo()
you will find the directory conf.d/
and the file error.log
GL
This message means you need to install and or activate postgresql extension in PHP
This solution works for me : To install postgresql extension
[sudo] apt-get install php-pgsql
after, for activating it, uncomment pgsql
and pdo-pgsql
extensions in etc/php/$PHP_VERSION/apache2/php.ini
file
Finally, type :
[sudo] /etc/init.d/apache2 restart
To restart apache server if you use apache such as was my case...
I had the same problem with another solution. I lost my around 4 hours to solve this problem. Please check the following to solve this problem.
Check php.ini
file and remove semicolon from this line
extension=pgsql
extension=pdo_pgsql
Restart your apache2 server
sudo service apache2 restart
Check if your PDO driver has updated in localhost phpinfo()
I did All the things right and still I had this problem. And you know why? Because I had several versions of php installed. So I was running php7.4
in my php cli but localhost was running on php7.2
. So always check your php versions.