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.
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.
In this file vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
they have
if ( ! isset($options['collate'])) {
$options['collate'] = 'utf8_unicode_ci';
}
Try changing it to utf8_general_ci
Also have a look here
http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/faq.html#how-do-i-set-the-charset-and-collation-for-mysql-tables
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With