UTF8 and mysql: enable UTF8 mode correctly
authorGalen Charlton <galen.charlton@liblime.com>
Thu, 27 Dec 2007 22:47:27 +0000 (16:47 -0600)
committerJoshua Ferraro <jmf@liblime.com>
Thu, 27 Dec 2007 23:23:58 +0000 (17:23 -0600)
Doc for DBD::mysql states that if not setting
mysql_enable_utf8 as part of the database
connect(), must do it before doing "set names utf8"

Signed-off-by: Chris Cormack <crc@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
C4/Context.pm

index 49b7435..48bf9a6 100644 (file)
@@ -605,8 +605,8 @@ sub _new_dbh
     if ( $db_driver eq 'mysql' ) { 
         # Koha 3.0 is utf-8, so force utf8 communication between mySQL and koha, whatever the mysql default config.
         # this is better than modifying my.cnf (and forcing all communications to be in utf8)
-        $dbh->do("set NAMES 'utf8'") if ($dbh);
         $dbh->{'mysql_enable_utf8'}=1; #enable
+        $dbh->do("set NAMES 'utf8'");
     }
     elsif ( $db_driver eq 'Pg' ) {
            $dbh->do( "set client_encoding = 'UTF8';" );