Use UTF8 for database connection when connecting to MySQL

This commit is contained in:
Graham Knop 2008-03-07 17:45:19 +00:00
parent 4a93766bf9
commit d9d524a2fe
4 changed files with 18 additions and 3 deletions

View file

@ -319,7 +319,10 @@ sub connect {
my $pass = shift;
my $params = shift;
my $dbh = DBI->connect($dsn,$user,$pass,{RaiseError=>0,AutoCommit=>1 });
my (undef, $driver) = DBI->parse_dsn($dsn);
my $dbh = DBI->connect($dsn,$user,$pass,{RaiseError => 0, AutoCommit => 1,
$driver eq 'mysql' ? (mysql_enable_utf8 => 1) : (),
});
unless (defined $dbh) {
$session->errorHandler->error("Couldn't connect to database: $dsn");