Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Sat, Jul 19, 8:57 AM

in-portal

Index: branches/unlabeled/unlabeled-1.1.2/utf.php
===================================================================
--- branches/unlabeled/unlabeled-1.1.2/utf.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.1.2/utf.php (revision 4205)
@@ -0,0 +1,65 @@
+<?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');
+
+$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
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.1.2.1
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property

Event Timeline