Use UTF8 for database connection when connecting to MySQL
This commit is contained in:
parent
4a93766bf9
commit
d9d524a2fe
4 changed files with 18 additions and 3 deletions
|
|
@ -1,4 +1,5 @@
|
|||
7.5.6
|
||||
- Use UTF8 for database connection when connecting to MySQL
|
||||
- Internationalized Calendar templates
|
||||
- fixed: exporting as HTML leaks sessions for inaccessible assets,
|
||||
- new YUI based date picker
|
||||
|
|
|
|||
|
|
@ -22,11 +22,18 @@ my $quiet; # this line required
|
|||
|
||||
my $session = start(); # this line required
|
||||
|
||||
# upgrade functions go here
|
||||
convertCacheToBinary($session);
|
||||
|
||||
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 {
|
||||
# my $session = shift;
|
||||
|
|
|
|||
|
|
@ -104,7 +104,11 @@ sub get {
|
|||
my $content = $data->[0];
|
||||
return undef unless ($content);
|
||||
# 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;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue