Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Sat, Jul 19, 1:41 PM

in-portal

Index: branches/unlabeled/unlabeled-1.1.2/utf.php
===================================================================
--- branches/unlabeled/unlabeled-1.1.2/utf.php (revision 4210)
+++ branches/unlabeled/unlabeled-1.1.2/utf.php (revision 4211)
@@ -1,65 +1,67 @@
<?php
$start = getmicrotime();
define('FULL_PATH', realpath(dirname(__FILE__)));
define('APPLICATION_CLASS', 'MyApplication');
include_once(FULL_PATH.'/kernel/kernel4/startup.php');
$application =& kApplication::Instance();
$application->Init();
header('Content-type: text/html; charset: utf-8');
+if (!defined('DEBUG_MODE') || !DEBUG_MODE) exit;
+
$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<br>";
$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'].')<br>';
// 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<br>";
$application->DB->Query($q);
$q = 'UPDATE `'.$table.'` SET `utf_'.$a_column['Field'].'` = BINARY(`'.$a_column['Field'].'`);';
echo "$q<br>";
$application->DB->Query($q);
$q = 'ALTER TABLE `'.$table.'` CHANGE `'.$a_column['Field'].'` `'.$a_column['Field'].'` '.$new_def.';';
echo "$q<br>";
$application->DB->Query($q);
$q = 'UPDATE `'.$table.'` SET `'.$a_column['Field'].'` = `utf_'.$a_column['Field'].'`;';
echo "$q<br>";
$application->DB->Query($q);
$q = 'ALTER TABLE `'.$table.'` DROP `utf_'.$a_column['Field'].'`;';
echo "$q<br>";
$application->DB->Query($q);
}
}
}
function getmicrotime()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.1.2/utf.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.1.2.1
\ No newline at end of property
+1.1.2.2
\ No newline at end of property

Event Timeline