3

Hey everybod out there :) I'm using CodeIgniter and Doctrine2 as my ORM. I'm having problem with storing and retrieving UTF-8 texts from my database.

I've red something about PostConnection Events but im not really sure where to add this stuff :/

My Database and the tables have UTF-8 Encoding.

Can some tell me how i can fix this? :)

greetings

soupdiver
  • 3,504
  • 9
  • 40
  • 68

1 Answers1

5

You have to tell your entityManager explicitly you want to use UTF-8. You don't show any code, so I just give you my snippet:

// $entityManager is an instance of EntityManager
// Add UTF8 handler to EntityManager
$entityManager->getEventManager()->addEventSubscriber(
                new \Doctrine\DBAL\Event\Listeners\MysqlSessionInit('utf8', 'utf8_unicode_ci')
);

This worked for me. Also, make sure you only use multibyte functions of PHP (http://php.net/manual/en/book.mbstring.php).

Rene Terstegen
  • 7,911
  • 18
  • 52
  • 74