[Catalyst] utf8 in mysql

Tobias Kremer list at funkreich.de
Wed Nov 28 15:45:31 GMT 2007


Quoting Angel Kolev <ankolev at gmail.com>:

> Hi all. I have problem when fetch data from mysql. All data is in utf8
> and in my phpmyadmin i can see all chars correctly. I dont know how to
> tell to my model to fetch data in utf8. With standart DBI module i can
> do it with :
>
> $dbh->do("set character set utf8");
> $dbh->do("set names utf8");

Try this:

__PACKAGE__->config(
    schema_class => 'MyApp::FooSchema',
    connect_info => [
        'your_dsn',
        'username',
        'password',
        {
            mysql_enable_utf8   => 1,
            on_connect_do       => [
                "SET NAMES 'utf8'",
                "SET CHARACTER SET 'utf8'",
            ],
        }
    ],
);

HTH,

--Tobias



More information about the Catalyst mailing list