sou*_*ver 3 php doctrine utf-8
嘿Everybod在那里:)我使用CodeIgniter和Doctrine2作为我的ORM.我在存储和检索数据库中的UTF-8文本时遇到问题.
关于PostConnection事件我有点红,但我不确定在哪里添加这些东西:/
我的数据库和表格有UTF-8编码.
有人能告诉我如何解决这个问题吗?:)
问候
您必须明确告诉您的entityManager您要使用UTF-8.你没有显示任何代码,所以我只给你我的代码片段:
// $entityManager is an instance of EntityManager
// Add UTF8 handler to EntityManager
$entityManager->getEventManager()->addEventSubscriber(
new \Doctrine\DBAL\Event\Listeners\MysqlSessionInit('utf8', 'utf8_unicode_ci')
);
Run Code Online (Sandbox Code Playgroud)
这对我有用.另外,请确保您只使用PHP的多字节函数(http://php.net/manual/en/book.mbstring.php).