[Dbix-class] Where to "encourage" UTF8...
Ash Berlin
ash_cpan at firemirror.com
Wed Dec 10 00:41:22 GMT 2008
On 10 Dec 2008, at 00:03, Paul Makepeace wrote:
> For reasons I'm not clear on our MySQL / DBIC / Catalyst set-up has
> lately started dropping utf8-ness. I had a dig around and there seem
> to be a few solutions.
>
> Matt's talk http://www.shadowcat.co.uk/catalyst/-talks/oscon/crucible.xul
> suggests, slide 92 (which sadly I can't copy/paste) using an
> on_connect_do. It doesn't say where exactly this goes but I'm assuming
> in the schema base class? It didn't help in any case :-)
>
> I read in http://dev.mysql.com/doc/refman/5.0/en/charset-general.html
> a way of setting character set results, so tried this,
>
> __PACKAGE__->config(
> schema_class => 'IDL::Schema',
> connect_info => [@IDL::Schema::connect_info],
> on_connect_do => [
> #'set names utf8',
> 'SET character_set_results="utf8"',
> ],
> );
>
> That didn't appear to do anything either.
>
> What /did/ work was, __PACKAGE__->load_components(qw/UTF8Columns/);
> and then individually setting uft8_columns(qw/name etc/);
>
> Any ideas why the first two didn't work? I'm not really excited about
> setting UTF8 on every text column...
>
> **
>
> Stabbing at it from the database side, the db is latin1,
>
> mysql> show variables like "character_set_database";
> +------------------------+--------+
> | Variable_name | Value |
> +------------------------+--------+
> | character_set_database | latin1 |
> +------------------------+--------+
>
> Attempting alter database default character set 'utf8'; alter database
> character set 'utf8'; seems too easy and doesn't appear to help
> either.
>
> Maybe it needs to be reloading from scratch as utf8 or something?
>
> P
What i did:
http://search.cpan.org/~capttofu/DBD-mysql-4.010/lib/DBD/mysql.pm#mysql_enable_utf8
- Set that in the 4th/options argument to connect.
- Make sure all my tables are set with the utf8 collation.
That was pretty much it - it just worked for me from then on.
-ash
More information about the DBIx-Class
mailing list