FaaPz / PDO

Just another PDO database library
MIT License
316 stars 103 forks source link

Error when setting charset #137

Closed f0rmig4 closed 3 years ago

f0rmig4 commented 4 years ago

Hello, I'm trying to set the charset (utf8 / latin1) and it's generating the following error:

Fatal error: Uncaught PDOException: SQLSTATE[08006] [7] invalid connection option "charset" in /home/clinicasalute/www/checkout_2/api/vendor/faapz/pdo/src/Database.php:24 Stack trace: #0 /home/clinicasalute/www/checkout_2/api/vendor/faapz/pdo/src/Database.php(24): PDO->construct('pgsql:host=pgsq...', 'myuser', 'mypass', Array) #1 /home/clinicasalute/www/checkout_2/api/db.php(24): FaaPz\PDO\Database->__construct('pgsql:host=local...', 'myuser', 'mypass') #2 /home/clinicasalute/www/checkout_2/api/api.php(64): db->construct() #3 /home/clinicasalute/www/checkout_2/api/index.php(5): api->create() #4 {main} thrown in /home/clinicasalute/www/checkout_2/api/vendor/faapz/pdo/src/Database.php on line 24

My code:

$dsn = 'pgsql:host=locahost;dbname=mydb;charset=utf8'; //charset=latin1 $usr = 'myuser'; $pwd = 'mypass';

$this->pdo = new \FaaPz\PDO\Database($dsn, $usr, $pwd);

if (!$this->pdo) { die('error connect pgsql'); }

kwhat commented 3 years ago

I am pretty sure this error is originating from the Postgres driver outside of this library. Double check your DSN.

0 faapz/pdo/src/Database.php(24): PDO->__construct('pgsql:host=pgsq...', 'myuser', 'mypass', Array)