FaaPz/PDO

Error when setting charset

Closed this issue · 1 comments

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

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)