lgomezma
lgomezma

Reputation: 1637

Persisting utf-8 data with Doctrine2 in Symfony2

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?

Upvotes: 6

Views: 3166

Answers (2)

codecowboy
codecowboy

Reputation: 10095

You also need the following entry in my.cnf:

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

Upvotes: 1

lgomezma
lgomezma

Reputation: 1637

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

Upvotes: 6

Related Questions