Search code examples
phpmysqlzend-frameworkdoctrine-orm

Storing polish characters utf8 doctrine 2 PHP, MySQL, Zend Framework


I have a CMS application written using the Zend Framework that allows you to translate the content. This works perfectly for German and French characters but is struggling with Polish, I've set up the database and connections correctly (as far as I can tell) but I'm still getting garbage stored and returned for Polish. The database is utf8_general_ci and so is the field. Doctrine connection params: resources.entityManager.connection.charset = "utf8" resources.entityManager.connection.default.parameters.driverOptions.1002 = "SET NAMES 'UTF8'"

The page with the database form posting the translation has: header('Content-type: text/html; charset=utf-8'); (at top) [meta http-equiv="Content-Type" content="text/html; charset=utf8" /] (in head tags)

I have no additional encoding on the string that saves to the databse (doctrine 2):

 $cn->setContent($pageForm->getValue($field));

So, French and German are quite happy with this, but the following Polish: specjalisty w produkcji zawieszeń, szybkość

Stores and views as: specjalisty w produkcji zawieszeń, szybkość

I'm going round in circles with this one so any thoughts would be very much appreciated.


Solution

  • The actual issue was how I was setting utf8 in Doctrine 2. I connect via an Entity Manager and the settings needed to go there rather than Bootstrap or application.ini

    'charset' => 'utf8', 'driverOptions' => array(1002=>'SET NAMES utf8')