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

Birgit Kellner birgit.kellner at univie.ac.at
Sun Jan 8 21:49:05 GMT 2006


Hello,

in November I posted a query to this list concerning utf8 problems with 
Class::DBI. Brian Philips was so nice as to help me on- and off-list, 
but we couldn't resolve the problem and I then had to devote my time to 
other issues, and let the matter rest for a while.

So here I go again:

The database uses utf8 encoding in MySQL 4.1.
With DBI, for some reason I have to execute "set names utf8" after 
setting up the database connection.
I have set all MySQL character variables to "utf8", but DBI doesn't seem 
to read them.

Rewriting the script for Class::DBI, I've now defined this class 
connection:
ILKB::DBI->connection("dbi:mysql:ilkb_test",'$usr','$pwd');

But how do I set the character set on this connection?
I was thinking of using "set_sql", but don't know the correct syntax.

Following Brian's advice, I tried several approaches that required 
modifying my.cnf and trying to get Class::DBI to read its parameters 
from there, but none of them worked. From the command-line, all database 
character variables are set to "utf8". Php scripts that run with the 
same MySQL installation have no problems with utf8 either. Hence I 
presume that it's to do with Perl, and with DBI, or Class::DBI in 
particular.

I sincerely hope that someone can help me, for otherwise I might have to 
drop Class::DBI (very reluctantly, as I really like it) and sadly revert 
to my hand-stitched relation-handling ...

Thank you very much,

Birgit Kellner




More information about the ClassDBI mailing list