From c4ed7ea903d78e57eae197837f5833a84c2c8ba3 Mon Sep 17 00:00:00 2001 From: qixinzhi Date: Tue, 14 May 2024 03:15:57 +0000 Subject: [PATCH] * Add upgrade bi data. --- module/upgrade/model.php | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/module/upgrade/model.php b/module/upgrade/model.php index 99169ff168..838f98d04c 100644 --- a/module/upgrade/model.php +++ b/module/upgrade/model.php @@ -165,6 +165,7 @@ class upgradeModel extends model $this->loadModel('program')->refreshStats(true); $this->loadModel('product')->refreshStats(true); $this->deletePatch(); + $this->upgradeBIData(); } /** @@ -8757,4 +8758,43 @@ class upgradeModel extends model $this->dao->delete()->from(TABLE_CONFIG)->where('module')->eq('programplan')->andWhere('section')->eq('custom')->andWhere('`key`')->eq('createFields')->exec(); return true; } + + /** + * 更新升级BI内置数据。 + * Import BI data. + * + * @access public + * @return bool + */ + public function upgradeBIData() + { + $this->loadModel('bi'); + + /* Prepare built-in sqls of bi. */ + $chartSQLs = $this->bi->prepareBuiltinChartSQL('update'); + $pivotSQLs = $this->bi->prepareBuiltinPivotSQL('update'); + $screenSQLs = $this->bi->prepareBuiltinScreenSQL('update'); + + $upgradeTables = array_merge($chartSQLs, $pivotSQLs, $screenSQLs); + + try + { + foreach($upgradeTables as $table) + { + $table = trim($table); + if(empty($table)) continue; + + $table = str_replace('`zt_', $this->config->db->name . '.`zt_', $table); + $table = str_replace('zt_', $this->config->db->prefix, $table); + if(!$this->dbh->query($table)) return false; + } + } + catch(Error $e) + { + a($e->getMessage()); + die; + } + + return true; + } }