* finish task #1893.

This commit is contained in:
wangyidong
2014-06-20 02:18:08 +00:00
parent e28cfa8efc
commit eee2645fdb
5 changed files with 85 additions and 100 deletions
+37
View File
@@ -710,6 +710,43 @@ class upgradeModel extends model
return true;
}
public function toLowerTable($build = 'basic')
{
$results = $this->dbh->query("show Variables like '%table_names'")->fetchAll();
$hasLowered = false;
foreach($results as $result)
{
if(strtolower($result->Variable_name) == 'lower_case_table_names' and $result->Value == 1)
{
$hasLowered = true;
break;
}
}
if($hasLowered) return true;
if($build == 'basic') $tables2Rename = $this->config->upgrade->lowerTables;
if(!isset($tables2Rename)) return false;
$tablesExists = $this->dbh->query('SHOW TABLES')->fetchAll();
foreach($tablesExists as $key => $table) $tablesExists[$key] = current((array)$table);
$tablesExists = array_flip($tablesExists);
foreach($tables2Rename as $oldTable => $newTable)
{
if(!isset($tablesExists[$oldTable])) continue;
$upgradebak = $newTable . '_othertablebak';
if(isset($tablesExists[$upgradebak])) $this->dbh->query("DROP TABLE `$upgradebak`");
if(isset($tablesExists[$newTable])) $this->dbh->query("RENAME TABLE `$newTable` TO `$upgradebak`");
$tempTable = $oldTable . '_zentaotmp';
$this->dbh->query("RENAME TABLE `$oldTable` TO `$tempTable`");
$this->dbh->query("RENAME TABLE `$tempTable` TO `$newTable`");
}
return true;
}
/**
* Process finishedBy and finishedDate of task.
*