A
A
Andrey2014-11-26 16:11:04
MySQL
Andrey, 2014-11-26 16:11:04

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

4 answer(s)
A
Andrey, 2014-11-26
@mcflys

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.

M
My joy, 2014-11-26
@t-alexashka

utf8_general_ci is needed :)

N
neolink, 2014-11-26
@neolink

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

A
Alex, 2014-11-26
@shoomyst

Well, if everything is fine on the site, then what is the problem, what does Doctrine2 have to do with it?
See the phpMyAdmin settings, why it does not give in utf8

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question