The following ZendCasts cast, shows a way to use doctrine 2 in a zend framework environment.
Using this configuration, how can I make the connection use a utf-8 charset so the magic of "SET NAMES 'utf8'"
will happen ?
What I'm really searching for is a way to configure it using the application.ini file.
If that's not possible using this configuration, how can this be done by code ? an _initDoctrine
method in the Bootstratp file ?
Thank you.
UPDATE
It appears there's a post connect event which handles this, but I don't see how can I set it up via application.ini (if possible at all).
If not, can I set it up via a bootstrap method ? Will the bootstrap method run before any other doctrine connection code run, when relying on the Bisna library ?
Since this is for Doctrine 2, and ZendCasts is using Bisna, I believe you can just add this to your configuration.ini file
I'm not exactly sure how to test if it is sticking or not but let us know.
If you are not using Bisna, you could simply do something like the following:
Pass the config stuff directly to EntityManager's connection options (although
driverOptions
is not documented)I'm using the following custom bootstrap resource to initialize doctrine therefore
$options
is in application.ini and is accessible there by$this->getOptions()
;It will bootstrap automatically if you put in application.ini
You could set the default table charset like that to utf8:
Quote:
Yes.
works fine for me
1002
is the integer value ofPDO::MYSQL_ATTR_INIT_COMMAND
:It is possible to add it via application.ini, provided you use ZendX_Doctrine2 (at https://github.com/mridgway/ZendX_Doctrine2) with MySQL.
Then here's the line you need in application.ini:
(1002 == PDO::MYSQL_ATTR_INIT_COMMAND)
Don't forget to correctly set
in your my.cnf
I have this in my bootstrap:
where in the application.ini you see
I think you can do something similar