colshrapnel / thebestpdowrapper

World's simplest PDO wrapper
35 stars 8 forks source link

PHP 7.1 Above - Fatal error: Uncaught PDOException: could not find driver in /home/project/public_html/api/v1/database-singleton.php:36 #12

Open yelnyafacee opened 6 years ago

yelnyafacee commented 6 years ago

hi, my project works fine for PHP 7.0

but for PHP 7.1, 7.2 above, the PDO wrapper is not working:

Error:

Fatal error: Uncaught PDOException: could not find driver in /home/project/public_html/api/v1/database-singleton.php:36 Stack trace:

line 35            $dsn = 'mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset='.DB_CHAR;
line 36            self::$instance = new PDO($dsn, DB_USER, DB_PASS, $opt);
#0 
/home/project/public_html/api/v1/database-singleton.php(36): PDO->__construct('mysql:host=loca...', 'db_name...', 'password', Array) 

#1 /home/project/public_html/api/v1/database-singleton.php(41): DB::instance()

#2 /home/project/public_html/api/v1/all-notifications-v2.php(62): DB::__callStatic('prepare', Array)

#3 /home/project/public_html/api/v1/all-notifications-v2.php(1426): getAllUserNotification('4')

#4 {main} thrown in /home/project/public_html/api/v1/database-singleton.php on line 36

klor commented 6 years ago

"Driver" is the database driver for MySQL, SQLite or other database you may be using. The driver needs to be enabled under Extensions in php.ini + restart your web server.

Sample extensions in php.ini:

;extension=pdo_firebird  <- this driver is disabled, so Firebird will not work
extension=pdo_mysql
;extension=pdo_oci
;extension=pdo_odbc
;extension=pdo_pgsql  <- this driver is disabled
extension=pdo_sqlite
spinningcat commented 4 years ago

I enabled

extension=pdo_pgsql extension=pgsql

but still got same error.

mfsiat commented 4 years ago

Excuse me please, but where is the php.ini file? Could anyone tell me where is this file located? Thank You

gagrano commented 3 years ago

There is something wrong with people who developed php-7.*. In php.ini the extension was originally like this (I uncomented): extension=pdo_mysql After I renamed to match the dll filename it started to work: extension=php_pdo_mysql.dll

thedaniela commented 3 years ago

Thanks @gagrano, saved my day

Franzab commented 1 week ago

@gagrano i've done this but I have the same problem