From 3c4c1bd967f7f5844f183a4f633bead0784dfda7 Mon Sep 17 00:00:00 2001 From: liugang Date: Tue, 3 Dec 2024 16:43:23 +0800 Subject: [PATCH] * [refac] using specific fields instead of * in sql. --- framework/control.class.php | 12 ++++++------ framework/router.class.php | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/framework/control.class.php b/framework/control.class.php index 89b4f0a73e..c5f480c34f 100644 --- a/framework/control.class.php +++ b/framework/control.class.php @@ -60,7 +60,7 @@ class control extends baseControl { if(isset($this->config->{$this->moduleName}->exportFields) or isset($this->config->{$this->moduleName}->list->exportFields)) { - $exportFields = $this->dao->select('*')->from(TABLE_WORKFLOWFIELD)->where('module')->eq($this->moduleName)->andWhere('canExport')->eq('1')->andWhere('buildin')->eq('0')->fetchAll('field'); + $exportFields = $this->dao->select('field, name')->from(TABLE_WORKFLOWFIELD)->where('module')->eq($this->moduleName)->andWhere('canExport')->eq('1')->andWhere('buildin')->eq('0')->fetchAll('field'); if(isset($this->config->{$this->moduleName}->exportFields)) { @@ -99,11 +99,11 @@ class control extends baseControl $moduleName = $this->moduleName; $methodName = $this->methodName; - $textareaFields = $this->dao->select('*')->from(TABLE_WORKFLOWFIELD)->where('module')->eq($this->moduleName)->andWhere('control')->eq('richtext')->andWhere('buildin')->eq('0')->fetchAll('field'); - if($textareaFields) + $fields = $this->dao->select('field')->from(TABLE_WORKFLOWFIELD)->where('module')->eq($this->moduleName)->andWhere('control')->eq('richtext')->andWhere('buildin')->eq('0')->fetchPairs(); + if($fields) { $editorIdList = array(); - foreach($textareaFields as $textareaField) $editorIdList[] = $textareaField->field; + foreach($fields as $field) $editorIdList[] = $field; if(!isset($this->config->{$moduleName})) $this->config->{$moduleName} = new stdclass(); if(!isset($this->config->{$moduleName}->editor)) $this->config->{$moduleName}->editor = new stdclass(); @@ -612,10 +612,10 @@ class control extends baseControl if($layouts) { - $allFields = $this->dao->select('*')->from(TABLE_WORKFLOWFIELD)->where('module')->eq($moduleName)->fetchAll('field'); + $allFields = $this->dao->select('field, `default`')->from(TABLE_WORKFLOWFIELD)->where('module')->eq($moduleName)->fetchPairs(); foreach($fieldList as $fieldName => $field) { - if(isset($allFields[$fieldName])) $field->default = $allFields[$fieldName]->default; + if(isset($allFields[$fieldName])) $field->default = $allFields[$fieldName]; } foreach($fieldList as $key => $field) diff --git a/framework/router.class.php b/framework/router.class.php index 03a63eb458..f4bc6882af 100755 --- a/framework/router.class.php +++ b/framework/router.class.php @@ -142,7 +142,7 @@ class router extends baseRouter $customMenus = array(); try { - $customMenus = $this->dbQuery('SELECT * FROM ' . TABLE_LANG . " WHERE `module`='common' AND `section`='mainNav' AND `lang`='{$this->clientLang}' AND `vision`='{$this->config->vision}'")->fetchAll(); + $customMenus = $this->dbQuery('SELECT `key`, `value` FROM ' . TABLE_LANG . " WHERE `module`='common' AND `section`='mainNav' AND `lang`='{$this->clientLang}' AND `vision`='{$this->config->vision}'")->fetchAll(); } catch(PDOException){} @@ -223,7 +223,7 @@ class router extends baseRouter /* When upgrading from version 12 to the paid version, the workflow table does not exist. */ try { - $flows = $this->dbQuery('SELECT * FROM ' . TABLE_WORKFLOW . " WHERE `buildin` = 0 AND `vision` = '{$this->config->vision}' AND status = 'normal' AND type = 'flow'")->fetchAll(); + $flows = $this->dbQuery('SELECT `module`, `name`, `navigator` FROM ' . TABLE_WORKFLOW . " WHERE `buildin` = 0 AND `vision` = '{$this->config->vision}' AND status = 'normal' AND type = 'flow'")->fetchAll(); foreach($flows as $flow) { if($flow->navigator == 'primary') $this->lang->mainNav->{$flow->module} = "{$this->lang->navIcons['workflow']} {$flow->name}|{$flow->module}|browse|"; @@ -376,7 +376,7 @@ class router extends baseRouter $customMenus = array(); try { - $customMenus = $this->dbQuery('SELECT * FROM' . TABLE_LANG . "WHERE `module`='common' AND `lang`='{$this->clientLang}' AND `section`='' AND `vision`='{$config->vision}'")->fetchAll(); + $customMenus = $this->dbQuery('SELECT `key`, `value` FROM' . TABLE_LANG . "WHERE `module`='common' AND `lang`='{$this->clientLang}' AND `section`='' AND `vision`='{$config->vision}'")->fetchAll(); } catch(PDOException){}