[CDBI] [Repost] Set utf8 character set on class connection?

Perrin Harkins perrin at elem.com
Mon Jan 9 20:38:26 GMT 2006

On Mon, 2006-01-09 at 21:24 +0100, Birgit Kellner wrote:
> use Class::DBI;
> package ILKB::DBI;
> use base 'Class::DBI';
> ILKB::DBI->connection("dbi:mysql:$db",'$usr','$pwd');
> ILKB::DBI->db_Main->do("set names utf8");

The danger here is that if you lose your connection, it will reconnect,
and will not re-run that SQL.  You have to override db_Main to fix that.
If you only use this in short command-line scripts and not in a
persistent environment like mod_perl, you may be okay.

- Perrin

More information about the ClassDBI mailing list