6
votes

I'm trying to persist some data that I get from a form in a MySQL database using Doctrine2 and Symfony 2. My problem is that this data is in Greek and although the Collation of the database and the fields is utf8_general_ci it Doctrine2 doesn't store correctly this characters.

I've checked that this characters are correct in my mapping class, so I guess that the problem is my Doctrine configuration. Any ideas of what it might be?

2

2 Answers

6
votes

I figure it out myself. I had to set Doctrine Dbal to utf8. For that I only needed to add the following to my config.yml:

doctrine:
    dbal:
      //rest of the configuration 
      charset:  utf8
1
votes

You also need the following entry in my.cnf:

collation-server = utf8_general_ci 
character-set-server = utf8