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

@ -1,4 +1,5 @@
7.5.6 7.5.6
- Use UTF8 for database connection when connecting to MySQL
- Internationalized Calendar templates - Internationalized Calendar templates
- fixed: exporting as HTML leaks sessions for inaccessible assets, - fixed: exporting as HTML leaks sessions for inaccessible assets,
- new YUI based date picker - new YUI based date picker

View file

@ -22,11 +22,18 @@ my $quiet; # this line required
my $session = start(); # this line required my $session = start(); # this line required
# upgrade functions go here convertCacheToBinary($session);
finish($session); # this line required finish($session); # this line required
sub convertCacheToBinary {
my $session = shift;
print "\tConverting database cache to binary data.\n" unless ($quiet);
$session->db->write('ALTER TABLE `cache` MODIFY COLUMN `content` mediumblob');
$session->db->write('DELETE FROM `cache`');
}
##------------------------------------------------- ##-------------------------------------------------
#sub exampleFunction { #sub exampleFunction {
# my $session = shift; # my $session = shift;

View file

@ -104,7 +104,11 @@ sub get {
my $content = $data->[0]; my $content = $data->[0];
return undef unless ($content); return undef unless ($content);
# Storable doesn't like non-reference arguments, so we wrap it in a scalar ref. # Storable doesn't like non-reference arguments, so we wrap it in a scalar ref.
return ${thaw($content)}; eval {
$content = thaw($content);
};
return undef unless $content;
return $$content;
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------

View file

@ -319,7 +319,10 @@ sub connect {
my $pass = shift; my $pass = shift;
my $params = 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) { unless (defined $dbh) {
$session->errorHandler->error("Couldn't connect to database: $dsn"); $session->errorHandler->error("Couldn't connect to database: $dsn");