From 04bacdbfb696ee063aa097bda3e58f0020d1db23 Mon Sep 17 00:00:00 2001 From: zhouxin Date: Wed, 10 Jul 2024 14:05:34 +0800 Subject: [PATCH] * [misc] The dm database cannot use alias for group by. --- lib/base/dao/dao.class.php | 5 +++++ lib/dao/dao.class.php | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/lib/base/dao/dao.class.php b/lib/base/dao/dao.class.php index 600633b7a1..52aa3cafaa 100644 --- a/lib/base/dao/dao.class.php +++ b/lib/base/dao/dao.class.php @@ -2501,11 +2501,16 @@ class baseSQL public function groupBy($groupBy) { if($this->inCondition and !$this->conditionIsTrue) return $this; + + //The dm database cannot use alias for group by + /* if(!preg_match('/^\w+[a-zA-Z0-9_`.]+$/', $groupBy)) { $groupBy = htmlspecialchars($groupBy); helper::end("Group is bad query, The group is $groupBy"); } + */ + $this->sql .= ' ' . DAO::GROUPBY . " $groupBy"; return $this; } diff --git a/lib/dao/dao.class.php b/lib/dao/dao.class.php index 5a8ea172de..da460191e3 100644 --- a/lib/dao/dao.class.php +++ b/lib/dao/dao.class.php @@ -340,11 +340,16 @@ class sql extends baseSQL public function groupBy($groupBy) { if($this->inCondition and !$this->conditionIsTrue) return $this; + + //The dm database cannot use alias for group by + /* if(!preg_match('/^[a-zA-Z0-9_`\.,\s\"]+$/', $groupBy)) { $groupBy = htmlspecialchars($groupBy); die("Group is bad query, The group is $groupBy"); } + */ + $this->sql .= ' ' . DAO::GROUPBY . " $groupBy"; return $this; }