* [perf] Fix condition of mao.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user