diff --git a/lib/base/dao/dao.class.php b/lib/base/dao/dao.class.php index b775563773..3f90846fb3 100644 --- a/lib/base/dao/dao.class.php +++ b/lib/base/dao/dao.class.php @@ -1897,6 +1897,8 @@ class baseSQL */ public function orderBy($order) { + if($this->inCondition and !$this->conditionIsTrue) return $this; + $order = str_replace(array('|', '', '_'), ' ', $order); /* Add "`" in order string. */ @@ -1941,6 +1943,7 @@ class baseSQL */ public function limit($limit) { + if($this->inCondition and !$this->conditionIsTrue) return $this; if(empty($limit)) return $this; stripos($limit, 'limit') !== false ? $this->sql .= " $limit " : $this->sql .= ' ' . DAO::LIMIT . " $limit "; return $this; @@ -1956,6 +1959,7 @@ class baseSQL */ public function groupBy($groupBy) { + if($this->inCondition and !$this->conditionIsTrue) return $this; $this->sql .= ' ' . DAO::GROUPBY . " $groupBy"; return $this; } @@ -1970,6 +1974,7 @@ class baseSQL */ public function having($having) { + if($this->inCondition and !$this->conditionIsTrue) return $this; $this->sql .= ' ' . DAO::HAVING . " $having"; return $this; } diff --git a/module/doc/model.php b/module/doc/model.php index 4cb8cab3f8..c276570502 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -152,6 +152,7 @@ class docModel extends model $docs = $this->dao->select('*')->from(TABLE_DOC)->where($docQuery)->andWhere('deleted')->eq(0)->orderBy($sort)->page($pager)->fetchAll(); } + $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'doc'); if($docs) return $docs; return array();