From 33e44b98a16d6f920c3a1baa53e6b1b6dfd78c5c Mon Sep 17 00:00:00 2001 From: qixinzhi Date: Wed, 15 Nov 2023 13:01:59 +0800 Subject: [PATCH] * Fix chart filter select item not display in screen. --- module/screen/model.php | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/module/screen/model.php b/module/screen/model.php index d2adc9d3a2..d5559a388b 100644 --- a/module/screen/model.php +++ b/module/screen/model.php @@ -767,20 +767,16 @@ class screenModel extends model if($table) $options = $this->dao->select("id, {$field}")->from($table)->fetchPairs(); } break; - case 'string': - if($field) + default: + if($field && $sql) { - if($sql) - { - $cols = $this->dbh->query($sql)->fetchAll(); - foreach($cols as $col) - { - $data = $col->$field; - $options[$data] = $data; - } - } + $options = $this->dao->select("tt.`$field`,tt.`$field`") + ->from("($sql)")->alias('tt') + ->groupBy("tt.`$field`") + ->orderBy("tt.`$field` desc") + ->fetchPairs(); } - break; + } $options = array_filter($options);