Skip to content

Commit

Permalink
merged added code to force mysql db to change default encoding during…
Browse files Browse the repository at this point in the history
… fresh installation
  • Loading branch information
toyomoyo committed Oct 18, 2006
1 parent 8b8a877 commit a6eb09d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions lib/ddllib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

?>

0 comments on commit a6eb09d

Please sign in to comment.