]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Make sure we have a DB connection before setting its charset
authorZach Copley <zach@controlyourself.ca>
Thu, 18 Jun 2009 19:19:19 +0000 (19:19 +0000)
committerZach Copley <zach@controlyourself.ca>
Thu, 18 Jun 2009 19:19:19 +0000 (19:19 +0000)
classes/Memcached_DataObject.php

index 33ac70dd045643a5a57ff87e58d383a0bc52bd2b..f945e94ff35b5fd85d72bb866c5a9639051301e7 100644 (file)
@@ -242,13 +242,16 @@ class Memcached_DataObject extends DB_DataObject
             if (common_config('db', 'type') == 'mysql' &&
                 common_config('db', 'utf8')) {
                 $conn = $DB->connection;
-                if ($DB instanceof DB_mysqli) {
-                    mysqli_set_charset($conn, 'utf8');
-                } else if ($DB instanceof DB_mysql) {
-                    mysql_set_charset('utf8', $conn);
+                if (!empty($conn)) {
+                    if ($DB instanceof DB_mysqli) {
+                        mysqli_set_charset($conn, 'utf8');
+                    } else if ($DB instanceof DB_mysql) {
+                        mysql_set_charset('utf8', $conn);
+                    }
                 }
             }
         }
         return $result;
     }
+
 }