Zend Framework 2 – doctrine: special characters problem

All my tables and the database are set to utf8_general_ci, yet I suddenly encountered a problem with ZF2 and saving data to the database. My test-entry “höhöhöhö” was saved like this:

Google search didn’t get me far, because the only hint I could find was an instruction to SET NAMES ‘UTF8’ in my database connection, but I was already doing that.
Since I used doctrine to save my data, I added the following to my doctrine.global.php:

                    'params' => array(
                        'host' => 'localhost',
                        'port'     => '3306',
                        'dbname' => 'table_name',
                        'charset' => 'utf8' //<---- here!

And suddenly the special chars worked!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.