mirror of
https://github.com/moodle/moodle.git
synced 2025-01-30 03:58:34 +01:00
merged added code to force mysql db to change default encoding during fresh installation
This commit is contained in:
parent
8b8a8779dc
commit
a6eb09d977
@ -140,6 +140,8 @@
|
||||
|
||||
/// 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
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user