Doctrine: special characters are not saved into database string field

diacritics, doctrine, mysql, symfony

Solution

You have to set the encoding for your entity manage connection string:

doctrine:
    dbal:
        driver: %database_driver%
        host: %database_host%
        port: %database_port%
        dbname: %database_name%
        user: %database_user%
        password: %database_password%
        charset: UTF8

This way you can have UTF8 characters on all the columns in your database.

Problem

im trying to save into a string field (mysql database) with doctrine (in symfony2): ``` $blogpost->setTitle = "Test !§$%&/()=? äöü ÄÖÜ :D"; $em = $this->getDoctrine()->getManager(); $em->persist($blogpost); $em->flush(); ``` but it saves me: "Test !" (the rest is missing) the entity is: ``` /** * @ORM\Column(type="string") */ protected $Title; ``` the mysql database is utf8_general_ci. (when i add an entity manually with phpmyadmin it works correctly.) i need to have the german umlauts. hope you can help me.

Original source