* fix bugs of upgrade module.

This commit is contained in:
wangchunsheng
2010-02-20 13:52:50 +00:00
parent 57415d1636
commit 9c505eb150
4 changed files with 26 additions and 6 deletions

View File

@@ -37,7 +37,9 @@ $lang->upgrade->warnningContent = <<<EOT
比如: mysqldump -u root -p zentao >zentao.bak
EOT;
$lang->upgrade->selectVersion = '选择版本';
$lang->upgrade->fromVersion = '升级版本';
$lang->upgrade->noteVersion = "务必选择正确的版本,否则会造成数据丢失。";
$lang->upgrade->fromVersion = '原来的版本';
$lang->upgrade->toVersion = '升级到';
$lang->upgrade->confirm = '确认要执行的SQL语句';
$lang->upgrade->sureExecute = '确认执行';

View File

@@ -75,13 +75,15 @@ class upgradeModel extends model
/* 更新PMS的版本设置。*/
public function updateVersion($version)
{
$item->company = $this->app->company->id;
$item->owner = 'system';
$item->section = 'global';
$item->key = 'version';
$item->value = $version;
$configID = $this->dao->select('id')->from(TABLE_CONFIG)
->where('owner')->eq('system')
->where('company')->eq($this->app->company->id)
->andWhere('owner')->eq('system')
->andWhere('section')->eq('global')
->andWhere('`key`')->eq('version')
->fetch('id');
@@ -105,16 +107,28 @@ class upgradeModel extends model
private function execSQL($sqlFile)
{
$mysqlVersion = $this->loadModel('install')->getMysqlVersion();
$sqls = explode(';', file_get_contents($sqlFile));
/* 去掉注释之后,再用;隔开。*/
$sqls = explode("\n", file_get_contents($sqlFile));
foreach($sqls as $key => $line)
{
$line = trim($line);
$sqls[$key] = $line;
if(strpos($line, '--') !== false or empty($line)) unset($sqls[$key]);
}
$sqls = explode(';', join("\n", $sqls));
foreach($sqls as $sql)
{
$sql = trim($sql);
if(empty($sql)) continue;
if(strpos($sql, 'CREATE') !== false and $mysqlVersion <= 4.1)
if($mysqlVersion <= 4.1)
{
$sql = str_replace('DEFAULT CHARSET=utf8', '', $sql);
$sql = str_replace('CHARACTER SET utf8 COLLATE utf8_general_ci', '', $sql);
}
$sql = str_replace('zt_', $this->config->db->prefix, $sql);
try
{

View File

@@ -34,7 +34,7 @@
}
else
{
echo html::linkButton($lang->upgrade->tohome, $this->createLink('index'));
echo html::linkButton($lang->upgrade->tohome, 'index.php');
}
?>
</td>

View File

@@ -28,7 +28,11 @@
<caption><?php echo $lang->upgrade->selectVersion;?></caption>
<tr>
<th class='w-p20 rowhead'><?php echo $lang->upgrade->fromVersion;?></th>
<td><?php echo html::select('fromVersion', $lang->upgrade->fromVersions, $version, 'class=select-3');?></td>
<td><?php echo html::select('fromVersion', $lang->upgrade->fromVersions, $version) . $lang->upgrade->noteVersion;?></td>
</tr>
<tr>
<th class='w-p20 rowhead'><?php echo $lang->upgrade->toVersion;?></th>
<td><?php echo $config->version;?></td>
</tr>
<tr>
<td colspan='2' class='a-center'><?php echo html::submitButton($lang->upgrade->common);?></td>