* Extend groupBy function of baseDAO.

This commit is contained in:
liugang
2018-04-16 15:49:48 +08:00
parent 532b35c2b3
commit 55fe6144b6
+19
View File
@@ -41,4 +41,23 @@ class dao extends baseDAO
*/
class sql extends baseSQL
{
/**
* 创建GROUP BY部分。
* Create the groupby part.
*
* @param string $groupBy
* @access public
* @return object the sql object.
*/
public function groupBy($groupBy)
{
if($this->inCondition and !$this->conditionIsTrue) return $this;
if(!preg_match('/^\w+[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;
}
}