Modified version of update 173 to handle special windows characters

This commit is contained in:
james 2010-06-09 15:11:14 +00:00
parent cb51fef47d
commit d5ed8a1fc4

View File

@ -58,6 +58,7 @@ function db_update_173_post(){
)
...
Keys uses the same arrangement for tracking the key fields in the tables
Now we need to run through those tables one at a time and convert them
*/
$totalFailCount = 0;
@ -80,12 +81,14 @@ function db_update_173_post(){
$query .= " FROM $tableName";
// fetch all of those values
mysql_query("SET NAMES latin1");
$updates = array();
$data = mysql_query($query);
while($record = mysql_fetch_array($data)){
$updates[] = $record;
}
// mysql_query("SET NAMES utf8");
mysql_query("SET NAMES utf8");
echo "Changing default character set on table \"$tableName\": ";
// now we have the data - let's convert the table
@ -99,7 +102,6 @@ function db_update_173_post(){
$totalFailCount ++;
}
}else{
//echo "ALTER TABLE `$tableName` DEFAULT CHARACTER SET 'utf8';\n";
echo " success\n";
}
@ -117,9 +119,9 @@ function db_update_173_post(){
}else{
$useComma = true;
}
$newValue = mb_convert_encoding($fieldValue, "UTF-8", "iso-8859-1");
$newValue = iconv("windows-1252", "iso-8859-1//TRANSLIT", $fieldValue);
$newValue = iconv("iso-8859-1", 'UTF-8//TRANSLIT', $newValue);
$query .= " `" . $fieldName . "` = '" . mysql_real_escape_string($newValue) . "'";
//$query .= sprintf(" `%s` = '%s'", $fieldName, mysql_real_escape_string($newValue));
}
$query .= " WHERE ";
for($n = 0; $n < count($keys[$tableName]); $n++){