function updateCharacterSet()
{
- foreach (array_reverse(array_keys($this->schema)) as $tbl){
+ foreach (array_keys($this->schema) as $tbl){
if(strpos($tbl, '__keys') !== false ){
continue;
}
- echo "CALL mysql_change_charset('{$tbl}') \n";
$ce = DB_DataObject::factory('core_enum');
- $ce->query("CALL mysql_change_charset('{$tbl}')");
- $ce->free();
+
+ $ce->query("
+ SELECT
+ CCSA.character_set_name csname,
+ CCSA.collation_name collatename
+ FROM
+ information_schema.`TABLES` T,
+ information_schema.`COLLATION_CHARACTER_SET_APPLICABILITY` CCSA
+ WHERE
+ CCSA.collation_name = T.table_collation
+ AND
+ T.table_schema = '{$ce->database()}' -- COLLATE utf8_unicode_ci
+ AND
+ T.table_name = '{$tbl}' -- COLLATE utf8_unicode_ci
+ ");
+
+ $ce->fetch();
+
+ if($ce->csname == 'utf8' && $ce->collatename == 'utf8_unicode_ci'){
+ echo "$tbl is Already utf8 \n";
+ continue;
+ }
+
+ $ce = DB_DataObject::factory('core_enum');
+ $ce->query("ALTER TABLE {$tbl} CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci");
+
+
}
}