I am using this config for my doctrine:
$config = array(
'name' => 'backend',
'host' => 'xxxxx',
'user' => 'xxxx',
'password' => 'xxxxx',
'dbname' => 'xxxx',
'driver' => 'pdo_mysql',
'charset' => 'UTF8',
);
But my database's using utf8_general_ci
. In result, when i get data from database, some characters can't show correctly as i want.
I tried adding:
'driveroptions'=>array(1002=>"SET NAMES utf8")
But it doesn't work. Could someone help me.
The character set and collation are 2 different things. I think you have 2 options.
1) Set the character set in MySQL config (the my.cnf file), by adding these lines in the [mysqld] block.
e.g.
[mysqld]
character-set-server=utf8
collation-server=utf8_general_ci
2) Try setting the collation in Doctrine config via 'options' setting.
e.g.
charset: UTF8
options:
1002: "SET NAMES 'UTF8' COLLATE 'utf8_unicode_ci'"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With