From 71192f3c8bfd731ee441c51f915345d0ef86ab0f Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Wed, 9 Jan 2008 12:40:54 +0000 Subject: [PATCH] Merged revisions 5259 via svnmerge from https://svn.webgui.org/plainblack/branch/WebGUI_7.4 ........ r5259 | graham | 2008-01-09 06:35:57 -0600 (Wed, 09 Jan 2008) | 1 line Use UTF8 for database connection when connecting to MySQL ........ --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/SQL.pm | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index f492dd2c4..6f6db6acc 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -22,6 +22,7 @@ 7.4.20 - fix: Assets with no committed versions may be left as orphans when parent is purged - fix: Tag cloud limited was to 50 least commonly used tags + - Use UTF8 for database connection when connecting to MySQL 7.4.19 - fix: Import Package does nothing when re-importing trashed package diff --git a/lib/WebGUI/SQL.pm b/lib/WebGUI/SQL.pm index bf82d1442..9ca83554d 100644 --- a/lib/WebGUI/SQL.pm +++ b/lib/WebGUI/SQL.pm @@ -319,7 +319,13 @@ sub connect { my $pass = shift; my $params = shift; - my $dbh = DBI->connect($dsn,$user,$pass,{RaiseError=>0,AutoCommit=>1 }); + my $driver; + if ($dsn =~ /^dbi:(\w+):/i) { + $driver = $1; + } + 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");