diff options
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/xxvd | 28 |
1 files changed, 13 insertions, 15 deletions
@@ -328,27 +328,25 @@ sub getDbh { my $dbh = DBI->connect($dsn, $usr, $pwd,{ PrintError => 1, AutoCommit => 1, + mysql_enable_utf8 => ($charset =~ m/UTF-8/ ? 1 : 0), + mysql_auto_reconnect => 1 }); if($dbh) { debug sprintf('Connect to database: %s successful.', $dsn); - if ($charset) { - my $NAMES = { - 'UTF-8' => 'utf8', - 'ISO-8859-1' => 'latin1', - 'ISO-8859-2' => 'latin2', - 'ISO-8859-5' => 'latin5', - 'ISO-8859-7' => 'latin7', - 'ISO-8859-15' => 'latin1', - }; - my $n = $NAMES->{$charset} || 'latin1'; - if (!($dbh->do("set character set '" . $n . "'"))) { - panic sprintf("Could not set charset: %s :", $n, $DBI::errstr); - } - #$dbh->{'mysql_enable_utf8'} = 1 if($n eq 'utf8'); + my $NAMES = { + 'UTF-8' => 'utf8', + 'ISO-8859-1' => 'latin1', + 'ISO-8859-2' => 'latin2', + 'ISO-8859-5' => 'latin5', + 'ISO-8859-7' => 'latin7', + 'ISO-8859-15' => 'latin1', + }; + my $n = $NAMES->{$charset} || 'latin1'; + if (!($dbh->do("set character set '" . $n . "'"))) { + panic sprintf("Could not set charset: %s :", $n, $DBI::errstr); } - $dbh->{'mysql_auto_reconnect'} = 1; } else { panic sprintf("Could not connect to database: %s :", $dsn, $DBI::errstr); &quit(1); |
