2009年5月13日星期三

Re: [fw-db] Use SET NAMES UTF8 on adapter config for mysql

Cristian Bichis-3 wrote:
>
> Hi,
>
> If i am connecting to MySQL through PDO_MYSQL i have an easy way to set
> SET NAMES UTF8;... Directly on db configuration:
>
> resources.db.adapter = PDO_MYSQL
> ................
> *resources.db.params.driver_options.1002 = "SET NAMES UTF8;"*
>
> How should i set this for a MYSQLI driver on configs ?
>
> --
> Best regards,
> Cristian Bichis
> www.zftutorials.com | www.zfforums.com | www.zftalk.com | www.zflinks.com
>
>
>


Have you tried this:

-----------------
If you work with Zend Framework, MySQLi as Driver and load your config out
of an INI file you can use it this way:

database.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"

OR according to the example above

$params = array(
'host' => 'localhost',
'username' => 'username',
'password' => 'password',
'dbname' => 'dbname',
'driver_options' => array(MYSQLI_INIT_COMMAND => 'SET NAMES UTF8;');
);
$db = Zend_Db::factory('Mysqli', $params);
------------------

Taken from comments on http://akrabat.com/2009/03/18/utf8-php-and-mysql/

Regards,

Goran Juric
http://gogs.info/
--
View this message in context: http://www.nabble.com/Use-SET-NAMES-UTF8-on-adapter-config-for-mysql-tp23522480p23528627.html
Sent from the Zend DB mailing list archive at Nabble.com.

没有评论: