Configure DBAL with Symfony2 to set encoding

Does anyone know a way to configure DBAL / Doctrine2 in the Symantec2 (symfony-reloaded) yml configuration file to execute the "set names" query? This question was asked elsewhere, but I could not find the correct answer.

http://fossplanet.com/f6/%5Bsymfony-users%5D-symfony2-sandbox-database-collation-49626/

If this configuration option is missing, how can I implement this with PHP? Or better: where is this a suitable place in a Symfony2 project?

+3
source share
2 answers

It is not possible yet. I am working to resolve this already, soon it will be possible.

+4
source

, , . , :

Symfony\Bundle\FrameworkBundle\Controller\Controller getEntityManager:

public function getEntityManager()
{
    $em = $this->get('doctrine.orm.entity_manager');
    static $utf8_set = false;
    if (!$utf8_set) {
        $em->getEventManager()->addEventSubscriber(new MysqlSessionInit('utf8','utf8_unicode_ci'));
        $utf8_set = true;
    }
    return $em;
}

, EntityManager (, , DoctrineController),

$this->getEntityManager()

.

$this->getEntityManager()->getRepository('What\Ever\Entity\I\Am\Looking\For')
+1

Source: https://habr.com/ru/post/1785409/


All Articles