in reply to Re: Re: Perl Mysql and UTF8
in thread Perl Mysql and UTF8
If you are not familiar with binds (or "placeholders", depending on the documentation source), then you should really look into them. The basic idea is that, instead of doing this:
do this:my $quotedvar = $dbh->quote($var); my $sql = "insert into mytable (mycolumn) values ($quotedvar)"; $dbh->do($sql);
But you should definiftely consult the DBI docs for more info on this (see the section under "Placeholder and Bind Values").my $sql = "insert into mytable (mycolumn) values (?)"; $dbh->do($sql,undef,$var);
I'm really not at all surprised that $dbh->quote(...) is mangling your data, because, well, that's what its job is, and apparently it is just getting a little bit over-zealous with its mangling. More to the point, it may not be character-encoding-aware... wheras simply binding the value just passes it directly through to the DBD. And, in the case of mysql, the DBD is probably capable of handling character-encoding well, since there is explicit functinoality around it in the database.
|
|---|