I'm looking for a way to connect to the postgresql database using UTF8 charset.
Currently, I have to send a query request after the connexion to specify the charset. It is not optimal at all...
$connect = new \PDO("pgsql:host=$this->host;dbname=$this->base", $this->user, $this->pass);
$connect->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$connect->query("SET NAMES '$this->charset'");
MySQL allows to pass a table on argument to specify the charset, I'm looking for the same thing.
$this->db = new \PDO("pgsql:host=$this->PARAM_hote;dbname=$this->PARAM_nom_bd", $this->PARAM_utilisateur, $this->PARAM_mot_passe, array(\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\''));
$this->db->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);