diff --git a/lib/base/mao/mao.class.php b/lib/base/mao/mao.class.php index c3aded9229..d1c0b15513 100644 --- a/lib/base/mao/mao.class.php +++ b/lib/base/mao/mao.class.php @@ -275,6 +275,8 @@ class baseMao */ public function select(string $fields = '*') { + $this->conditions = []; + $this->setFields(explode(',', str_replace(' ', '', $fields))); return $this; } @@ -297,14 +299,14 @@ class baseMao * 开始条件判断。 * Begin condition judge. * - * @param bool $condition + * @param bool|string $condition * @access public * @return static|sql the sql object. */ - public function beginIF(bool $conditionResult) + public function beginIF(bool|string $conditionResult) { $this->isConditionChecking = true; - $this->conditionIsTrue = $conditionResult; + $this->conditionIsTrue = (bool)$conditionResult; return $this; } diff --git a/module/setting/model.php b/module/setting/model.php index a8bd3e6e02..f422ba7572 100644 --- a/module/setting/model.php +++ b/module/setting/model.php @@ -226,7 +226,8 @@ class settingModel extends model $params['section'] = isset($params['section']) ? $params['section'] : ''; $params['key'] = isset($params['key']) ? $params['key'] : ''; - return $this->dao->$method('*')->from(TABLE_CONFIG)->where('1 = 1') + $access = $method == 'select' ? $this->mao : $this->dao; + return $access->$method('*')->from(TABLE_CONFIG)->where('1 = 1') ->beginIF($params['vision'])->andWhere('vision')->in($params['vision'])->fi() ->beginIF($params['owner'])->andWhere('owner')->in($params['owner'])->fi() ->beginIF($params['module'])->andWhere('module')->in($params['module'])->fi() @@ -245,7 +246,7 @@ class settingModel extends model public function getSysAndPersonalConfig(string $account = ''): array { $owner = 'system,' . ($account ? $account : ''); - $records = $this->dao->select('*')->from(TABLE_CONFIG) + $records = $this->mao->select('*')->from(TABLE_CONFIG) ->where('owner')->in($owner) ->beginIF(!$this->app->upgrading)->andWhere('vision')->in(array('', $this->config->vision))->fi() ->orderBy('id')