Saving utf-8 data with Doctrine2 in Symfony2

I am trying to save some data that I get from a form in a MySQL database using Doctrine2 and Symfony 2. My problem is that the data is in Greek, and although the sorting of the database and fields is utf8_general_ci, this Doctrine2 does not save the correct characters .

I checked that these characters are correct in my mapping class, so I think the problem is in my Doctrine configuration. Any ideas on what this could be?

+6
source share
2 answers

I realized that myself. I had to install the Dbal Doctrine in utf8. To do this, I needed to add the following to my config.yml:

doctrine: dbal: //rest of the configuration charset: utf8 
+6
source

You will also need the following entry in my.cnf:

 collation-server = utf8_general_ci character-set-server = utf8 
+1
source

Source: https://habr.com/ru/post/900537/


All Articles