开发者

Doctrine - load a YAML fixture with French characters

开发者 https://www.devze.com 2023-01-27 04:13 出处:网络
My Doctrine 1.2 is integrated inside CodeIgniter as a hook and I know that my char-set is utf8 with collation utf8_unicode_ci.

My Doctrine 1.2 is integrated inside CodeIgniter as a hook and I know that my char-set is utf8 with collation utf8_unicode_ci.

I have two YAML files, one for creating the DB and its tables and one to load some test data. My data can contain French accents (çéïë...). In my schama.yml I have correctly specified the collation and char-set:

options:
  type: INNODB
  charset: utf8
  collate: utf8_unicode_ci

I double checked the settings开发者_运维问答 in phpMyAdmin, everything is correct.

When I run my doctrine script from commandline to load my fixture to my one of my tables, all the French accents are replaced by junk!

Am I missing a setting or configuration or is there a bug in Doctrine?


You should have in your /config/database.php Doctrine connection:

// Load the Doctrine connection
$doctrine = Doctrine_Manager::connection($db['default']['dsn'], $db['default']['database']);

To fix the problem with the encoding you have to add this line:

$doctrine->exec('set names utf8');
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号