/// 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
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
+ }
+}
+
?>