Symfony2 Charset options for queries

I have a project in Symfony2 that works well on my localhost, but after moving it to an external server, the problem started.

  • I do not see any result names from the database containing the Polish character
  • In the profiler, I checked the requests:
    • Parameters section has correct encoding
    • "runnable query" has the same parameters, but with poor encoding

eg:

(...) WHERE ((((c1_.name LIKE '%Å %') OR (c3_.name LIKE '%Å %') OR (..) Parameters: ['%ś%', '%ś%', (...)]

All database tables have charset = utf8_unicode_ci.

In config.yml I install

 doctrine: dbal: charset: UTF8 

Setting frame encoding does not work.

Test

/config.php says:

 RECOMMENDATIONS: 1. Install and enable a PHP accelerator like APC (highly recommended). 2. Set short_open_tag to off in php.ini*. 3. Set magic_quotes_gpc to off in php.ini*. * Changes to the php.ini file must be done in "/usr/local/php/php.ini". 

But, unfortunately, I do not have access to php.ini on this server. Is it possible that this problem is caused by magic_quotes_gpc? I also do not have access to the command line, so I added the project (database, file system, providers) via ftp and phpmyadmin.

Becouse I have no problems on my local host, I think that this is a problem with the server configuration, and I do not have access to this, the only way I can see is to try changing the configuration of the charset QueryBuilder. Where can i do this? Do you know what else could cause this problem?

thanks

+7
source share
1 answer

Found solution: To install "SET NAMES utf8", I changed the configuration of the doctrine

 doctrine: dbal: driver: %database_driver% host: %database_host% port: %database_port% dbname: %database_name% user: %database_user% password: %database_password% charset: UTF8 options: 1002: "SET NAMES 'UTF8'" 

Now it works great.

+9
source

All Articles