]> git.mjollnir.org Git - moodle.git/commitdiff
merged added code to force mysql db to change default encoding during fresh installation
authortoyomoyo <toyomoyo>
Wed, 18 Oct 2006 07:26:04 +0000 (07:26 +0000)
committertoyomoyo <toyomoyo>
Wed, 18 Oct 2006 07:26:04 +0000 (07:26 +0000)
admin/index.php
lib/ddllib.php

index cc6dcb137e4fee3ad8c547a9a1f04b0b1e915c6f..de37e4aab1ce038e9bc9bd1007b37273979632eb 100644 (file)
 
     /// Both old .sql files and new install.xml are supported
     /// But we prioritise install.xml (XMLDB) if present
+    
+        change_db_encoding(); // first try to change db encoding to utf8
         $status = false;
         if (file_exists("$CFG->libdir/db/install.xml")) {
             $status = install_from_xmldb_file("$CFG->libdir/db/install.xml"); //New method
index 4c48f7e1a147453a06fd042a816020f4ccc9189e..2eefddabc30f812e92bcd2cef7549ea864e1ecc7 100644 (file)
@@ -1140,4 +1140,15 @@ function rename_index($table, $index, $newname, $continue=true, $feedback=true)
     return execute_sql_arr($sqlarr, $continue, $feedback);
 }
 
+/* trys to change default db encoding to utf8, if empty db
+ */
+function change_db_encoding() {
+    global $CFG, $db;  
+    // try forcing utf8 collation, if mysql db and no tables present
+    if (!$db->Metatables() && ($CFG->dbtype=='mysql')) {
+        $SQL = 'ALTER DATABASE '.$CFG->dbname.' CHARACTER SET utf8';
+        execute_sql($SQL, false); // silent, if it fails it fails
+    }
+}
+
 ?>