Sorry, should have explained it a little more :-)

I just run that query once before the first "real" query, something like
this:

$dbAdapter->query('SET NAMES UTF8');

After running that once, you should be good for the rest of the connection.
In web applications where pretty every controller/action will need a
database connection I just do it right after I initialize the DB adapter:

        $dbAdapter = Zend_Db::factory($this->_config->database));
        $dbAdapter->query('SET NAMES UTF8');
        Zend_Registry::getInstance()->dbAdapter = $dbAdapter;

Of course, this would open up an unnecessary database connection for
controllers/actions that don't need database connections. I don't have a
good answer for you on that - but basically you'd have to only run that
query when you know you'll need a database connection.

If anyone has a better way of doing this, I'd love to hear about it!

Thanks,
Bradley

On Tue, Sep 30, 2008 at 5:07 PM, Rob Riggen <[EMAIL PROTECTED]> wrote:

> Surely you don't do that on every call?
>
> I'm using Zend_Db_Table so I'm not necessarily writing queries - where
> can/should this be done?
>
> Thanks!
>
> Rob
>
>
> On Tue, Sep 30, 2008 at 5:04 PM, Bradley Holt <[EMAIL PROTECTED]>wrote:
>
>> Hi Rob - I usually do this by issuing a 'SET NAMES UTF8' query.
>>
>>
>> On Tue, Sep 30, 2008 at 4:59 PM, Rob Riggen <[EMAIL PROTECTED]>wrote:
>>
>>> Is there a way to force the character set on mysql db connections to
>>> UTF-8?
>>>
>>> Thanks,
>>>
>>> Rob
>>>
>>> *Robert Riggen* - Zend Certified Engineer
>>> *Big Yellow Technologies, LLC*
>>>
>>> Essex Junction, VT 05452
>>> 802.578.6719
>>> [EMAIL PROTECTED]
>>>
>>>
>>
>>
>> --
>> Bradley Holt
>> [EMAIL PROTECTED]
>>
>>
>


-- 
Bradley Holt
[EMAIL PROTECTED]

Reply via email to