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

Dan Rowles d.rowles at outcometechnologies.com
Mon Jan 9 10:09:44 GMT 2006


To call arbitrary SQL on your connection, you should do something like:-

__PACKAGE__->db_Main->prepare("blah");

Dan





Birgit Kellner wrote:
> 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
> 
> _______________________________________________
> ClassDBI mailing list
> ClassDBI at lists.digitalcraftsmen.net
> http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi

-- 
Dan Rowles
Outcome Technologies

_________________________________

t: +44 (0)207 656 2460
f: +44 (0)709 230 6588
m: +44 (0)798 076 8143
e: d.rowles at outcometechnologies.com
w: http://www.outcometechnologies.com
BUPA House
15-19 Bloomsbury Way
London WC1A 2BA
_________________________________

***This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they are
addressed. If you receive this message in error, please return it to the
sender.***




More information about the ClassDBI mailing list