Doctrine: special characters not stored in database string field
im trying to save in a row field (mysql database) using 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)
an object:
/**
* @ORM\Column(type="string")
*/
protected $Title;
mysql database - utf8_general_ci.
(when I add the object manually using phpmyadmin it works correctly.)
I need to have German umlauts. hope you can help me.
+3
source to share
2 answers
You have to set the encoding for your entity to control the 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 in all columns of your database.
+3
source to share