merged added code to force mysql db to change default encoding during fresh installation

This commit is contained in:
toyomoyo 2006-10-18 07:26:04 +00:00
parent 8b8a8779dc
commit a6eb09d977
2 changed files with 13 additions and 0 deletions

View File

@ -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

View 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
}
}
?>