* [refactor] Refactor SQL processing for database installation and upgrade
- Extract SQL processing methods to install model for better reusability - Add replaceContantsInSQL() and appendMySQLTableOptions() public methods - Unify SQL constants replacement across installation and upgrade modules - Remove duplicate SQL processing code in extension and upgrade models - Fix __TABLE__ to __DATABASE__ in zentao.sql for consistency - Improve code maintainability and reduce duplication
This commit is contained in:
@@ -123,9 +123,8 @@ class installModel extends model
|
||||
{
|
||||
$this->dbh->useDB($this->config->db->name);
|
||||
|
||||
$dbCharset = $this->dbh->getDatabaseCharsetAndCollation($this->config->db->name);
|
||||
$dbFile = $this->app->getAppRoot() . 'db' . DS . 'zentao.sql';
|
||||
$tables = explode(';', file_get_contents($dbFile));
|
||||
$dbFile = $this->app->getAppRoot() . 'db' . DS . 'zentao.sql';
|
||||
$tables = explode(';', file_get_contents($dbFile));
|
||||
|
||||
foreach($tables as $table)
|
||||
{
|
||||
|
||||
@@ -16,15 +16,6 @@ class upgradeModel extends model
|
||||
{
|
||||
static $errors = array();
|
||||
|
||||
/**
|
||||
* 数据库版本。
|
||||
* Database version.
|
||||
*
|
||||
* @var string
|
||||
* access public
|
||||
*/
|
||||
public $databaseVersion = '';
|
||||
|
||||
public $fromVersion = '';
|
||||
|
||||
public $fromEdition = '';
|
||||
@@ -40,7 +31,6 @@ class upgradeModel extends model
|
||||
{
|
||||
parent::__construct();
|
||||
$this->loadModel('setting');
|
||||
$this->databaseVersion = $this->loadModel('install')->getDatabaseVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -10854,7 +10844,8 @@ class upgradeModel extends model
|
||||
{
|
||||
if($this->config->db->driver != 'mysql') return true;
|
||||
|
||||
if(version_compare($this->databaseVersion, '5.6', '<')) return true;
|
||||
$dbVersion = $this->loadModel('install')->getDatabaseVersion();
|
||||
if(version_compare($dbVersion, '5.6', '<')) return true;
|
||||
|
||||
/* 获取服务器的字符集和排序规则。Get server charset and collation. */
|
||||
$result = $this->dbh->getServerCharsetAndCollation($this->config->db->name);
|
||||
|
||||
Reference in New Issue
Block a user