Skip to content

Instantly share code, notes, and snippets.

@Ocramius
Created June 3, 2012 13:33
Show Gist options
  • Save Ocramius/2863521 to your computer and use it in GitHub Desktop.
Save Ocramius/2863521 to your computer and use it in GitHub Desktop.
Setting up Doctrine DBAL to use UTF-8 in MySQL connections
<?php
use Doctrine\DBAL\Event\Listeners\MysqlSessionInit;
/* ... */
if(
isset($options['encoding'])
&& $this->_em->getConnection()->getDriver() instanceof MysqlDriver
) {
$this
->_em
->getEventManager()
->addEventSubscriber(new MysqlSessionInit(
$options['encoding'],
isset($options['collation']) ? $options['collation'] : false
));
}
/* ... */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment