Answer the question
In order to leave comments, you need to log in
How to configure Doctrine2 to save Cyrillic normally in the database?
Problem: I'm saving a Doctrine2 entity in ZendFramework2. If the database is opened through phpMyAdmin, all Russian words are displayed in this form: Although the site normally displays Russian characters. Table cell encoding utf8_unicode_ci.
Help me set up Doctrine2 so that it normally saves Russian words to the database.
UPD: the situation is the same with utf8_general_ci encoding.
UPD2: The problem is not in the server and not in phpMyAdmin, as with other sites that do not use the doctrine, everything is ok.
Answer the question
In order to leave comments, you need to log in
Found a solution. Maybe someone will need it:
Open the doctrine configuration file: /config/autoload/doctrine.local.php
Add these cells to the doctrine/connection/orm_default/params array:
'charset' => 'utf8',
'driverOptions' => array (
1002 => 'SET NAMES utf8'
),
We'll have to re-save all the values, because these krakozyabry will start showing on the site.
It is desirable to check this setting at the stage of application development.
utf8_unicode_ci is not an encoding, but a character mapping table (used to compare strings > <= etc.)
when you connect to the MySQL server you can set the encoding you want to communicate with the server in, doctrine does this itself (utf-8 by by default). and phpmyadmin does not
, you can set the default encoding for client connections in the mysql config:
# CLIENT SECTION
[mysql]
default-character-set=utf8
# SERVER SECTION
[mysqld]
default-character-set=utf8
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question