Index: branches/unlabeled/unlabeled-1.1.2/utf.php =================================================================== diff -u --- branches/unlabeled/unlabeled-1.1.2/utf.php (revision 0) +++ branches/unlabeled/unlabeled-1.1.2/utf.php (revision 4205) @@ -0,0 +1,65 @@ +Init(); + + +header('Content-type: text/html; charset: utf-8'); + +$target_charset = 'utf8'; +$target_collation = 'utf8_general_ci'; + +$query = 'SHOW TABLES'; +$tables = $application->DB->GetCol($query); + +ini_set('max_execution_time', 0); + +foreach ($tables as $table) +{ + echo "scanning $table
"; + $columns = $application->DB->Query('SHOW FULL COLUMNS FROM '.$table); + foreach ($columns as $a_column) { + if ($a_column['Collation'] != 'NULL') { + echo 'processing column '.$a_column['Field'].' ('.$a_column['Collation'].')
'; + +// ALTER TABLE `inp_Addresses` ADD `utf_To` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER `To` ; + + $new_def = $a_column['Type'].' CHARACTER SET '.$target_charset.' COLLATE '.$target_collation.' '.($a_column['Null'] == 'YES' ? 'NULL':'NOT NULL'); + $q = 'ALTER TABLE `'.$table.'` ADD `utf_'.$a_column['Field'].'` '.$new_def.' AFTER `'.$a_column['Field'].'`;'; + echo "$q
"; + $application->DB->Query($q); + + $q = 'UPDATE `'.$table.'` SET `utf_'.$a_column['Field'].'` = BINARY(`'.$a_column['Field'].'`);'; + echo "$q
"; + $application->DB->Query($q); + + $q = 'ALTER TABLE `'.$table.'` CHANGE `'.$a_column['Field'].'` `'.$a_column['Field'].'` '.$new_def.';'; + echo "$q
"; + $application->DB->Query($q); + + $q = 'UPDATE `'.$table.'` SET `'.$a_column['Field'].'` = `utf_'.$a_column['Field'].'`;'; + echo "$q
"; + $application->DB->Query($q); + + $q = 'ALTER TABLE `'.$table.'` DROP `utf_'.$a_column['Field'].'`;'; + echo "$q
"; + $application->DB->Query($q); + + } + } +} + + + +function getmicrotime() +{ + list($usec, $sec) = explode(" ", microtime()); + return ((float)$usec + (float)$sec); +} +?> \ No newline at end of file