* finish task #946.

This commit is contained in:
wangyidong
2012-11-21 07:54:52 +00:00
parent fa743d05d4
commit 541d8835f8
2 changed files with 60 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
<?php
include dirname(dirname(__FILE__)) . "/config/my.php";
if($config->requestType == 'PATH_INFO')
{
system('php ztcli "http://localhost/admin-renameTable"');
}
elseif($config->requestType == 'GET')
{
system('php ztcli "http://localhost/?m=admin&f=renameTable"');
}
+49
View File
@@ -112,6 +112,55 @@ class admin extends control
}
}
/**
* Rename table for from windows to linux.
*
* @access public
* @return void
*/
public function renameTable()
{
$renameTables = array(
'zt_casestep' => 'zt_caseStep' ,
'zt_doclib' => 'zt_docLib' ,
'zt_grouppriv' => 'zt_groupPriv' ,
'zt_productplan' => 'zt_productPlan' ,
'zt_projectproduct' => 'zt_projectProduct' ,
'zt_projectstory' => 'zt_projectStory' ,
'zt_relationoftasks' => 'zt_relationOfTasks',
'zt_storyspec' => 'zt_storySpec' ,
'zt_taskestimate' => 'zt_taskEstimate' ,
'zt_testresult' => 'zt_testResult' ,
'zt_testrun' => 'zt_testRun' ,
'zt_testtask' => 'zt_testTask' ,
'zt_usergroup' => 'zt_userGroup' ,
'zt_userquery' => 'zt_userQuery' ,
'zt_usertpl' => 'zt_userTPL'
);
$existTables = $this->dbh->query('SHOW TABLES')->fetchAll();
foreach($existTables as $key => $table) $existTables[$key] = current((array)$table);
$existTables = array_flip($existTables);
foreach($renameTables as $oldTable => $newTable)
{
if(isset($existTables[$newTable]))
{
echo "Has existed table '$newTable'\n";
}
elseif(!isset($existTables[$oldTable]))
{
echo "No found table '$oldTable'\n";
}
else
{
$this->dbh->query("RENAME TABLE `$oldTable` TO `$newTable`");
echo "RENAME TABLE `$oldTable` TO `$newTable`\n";
}
}
echo "Finish!\n";
}
/**
* Confirm clear data.
*