I see lots of talk about changing query_factory.php to accommodate UTF-8, but for admin there is also query_factory.php
I see no mention of modding this as well. I did and all seems to work there fine now too.
Also for changing your database after the fact, instead of going in and changing each field in each table, the following script works nicely. It will output a rather large list of alter table sql that you can copy and paste into phpmyadmin and change all at once. I didn't write this, but have used it and my confidence is high. It will also pickup and generate sql for any tables your other mods have added.
Use at your own risk.
Code:
<?php
// this script will output the queries need to change all fields/tables to a different collation
// it is HIGHLY suggested you take a MySQL dump prior to running any of the generated
// this code is provided as is and without any warranty
die("Make a backup of your MySQL database then remove this line");
set_time_limit(0);
// collation you want to change:
$convert_from = 'latin1_swedish_ci';
// collation you want to change it to:
$convert_to = 'utf8_general_ci';
// character set of new collation:
$character_set= 'utf8';
$show_alter_table = true;
$show_alter_field = true;
// DB login information
$username = 'user';
$password = 'pass';
$database = 'dbname';
$host = 'localhost';
mysql_connect($host, $username, $password);
mysql_select_db($database);
$rs_tables = mysql_query(" SHOW TABLES ") or die(mysql_error());
print '<pre>';
while ($row_tables = mysql_fetch_row($rs_tables)) {
$table = mysql_real_escape_string($row_tables[0]);
// Alter table collation
// ALTER TABLE `account` DEFAULT CHARACTER SET utf8
if ($show_alter_table) {
echo("ALTER TABLE `$table` DEFAULT CHARACTER SET $character_set;\r\n");
}
$rs = mysql_query(" SHOW FULL FIELDS FROM `$table` ") or die(mysql_error());
while ($row=mysql_fetch_assoc($rs)) {
if ($row['Collation']!=$convert_from)
continue;
// Is the field allowed to be null?
if ($row['Null']=='YES') {
$nullable = ' NULL ';
} else {
$nullable = ' NOT NULL';
}
// Does the field default to null, a string, or nothing?
if ($row['Default']=='NULL') {
$default = " DEFAULT NULL";
} else if ($row['Default']!='') {
$default = " DEFAULT '".mysql_real_escape_string($row['Default'])."'";
} else {
$default = '';
}
// Alter field collation:
// ALTER TABLE `account` CHANGE `email` `email` VARCHAR( 50 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL
if ($show_alter_field) {
$field = mysql_real_escape_string($row['Field']);
echo "ALTER TABLE `$table` CHANGE `$field` `$field` $row[Type] CHARACTER SET $character_set COLLATE $convert_to $nullable $default; \r\n";
}
}
}
?>
Make sure to edit in your proper username and passwd and stuff and do a backup before running the output of this script.
Kudos to whoever wrote this, it has saved me much time.
Bookmarks