From a11e5a6bd8e40f597a3d83ae15a1e2a625a682bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=8B=E8=BE=B0=E8=BD=A9?= Date: Fri, 7 Apr 2023 17:17:33 +0800 Subject: [PATCH 1/2] * Finish chart result query select dropmenu. --- module/chart/model.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/module/chart/model.php b/module/chart/model.php index 4be9cfcc82..c6b0c9defc 100644 --- a/module/chart/model.php +++ b/module/chart/model.php @@ -575,7 +575,7 @@ class chartModel extends model * @access public * @return array */ - public function getSysOptions($type, $object = '', $field = '') + public function getSysOptions($type, $object = '', $field = '', $sql = '') { $options = array('' => ''); switch($type) @@ -611,14 +611,21 @@ class chartModel extends model $options = $this->dao->select("id, {$field}")->from($table)->fetchPairs(); } break; - /*case 'string': + case 'string': if($field) { - $table = zget($this->config->objectTables, $object); - $options = $this->dao->select("{$field}, {$field}")->from($table)->fetchPairs(); + $options = array(); + if($sql) + { + $cols = $this->dbh->query($sql)->fetchAll(); + foreach($cols as $col) + { + $data = $col->$field; + $options[$data] = $data; + } + } } break; - */ } return $options; From a9470cb41155aae0edf88d82932e4c1de80fdf89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=8B=E8=BE=B0=E8=BD=A9?= Date: Mon, 10 Apr 2023 11:17:44 +0800 Subject: [PATCH 2/2] * Modify for commit . --- module/chart/model.php | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/module/chart/model.php b/module/chart/model.php index c6b0c9defc..a1e1fa08a0 100644 --- a/module/chart/model.php +++ b/module/chart/model.php @@ -612,17 +612,13 @@ class chartModel extends model } break; case 'string': - if($field) + if($field and $sql) { - $options = array(); - if($sql) + $cols = $this->dbh->query($sql)->fetchAll(); + foreach($cols as $col) { - $cols = $this->dbh->query($sql)->fetchAll(); - foreach($cols as $col) - { - $data = $col->$field; - $options[$data] = $data; - } + $data = $col->$field; + $options[$data] = $data; } } break;