PDO accentuation problem mysql php

1

I'm using this class to manipulate records in MySQL using PDO link

But I enter ééé and enter éé into the bank

the bank is uft8 the script header is in uft8.

    
asked by anonymous 09.03.2015 / 21:09

1 answer

6

Try to apply the character set directly on the DB call like this:

$db = new db("mysql:host=127.0.0.1;port=8889;dbname=mydb", charset=UTF8, "dbuser", "dbpasswd");
$db->exec("SET CHARACTER SET utf8");

or in the class constructor:

$options = array(
    PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
); 
public function __construct($dsn, $user="", $passwd="", $options) {
  //
}
    
09.03.2015 / 21:34