diff --git a/dblayeroo.php b/dblayeroo.php index 13a87e6..965254d 100644 --- a/dblayeroo.php +++ b/dblayeroo.php @@ -1268,7 +1268,7 @@ class dblayeroo private $whereValues = array (); /** The columns in GROUP BY condition */ - private $groupByExpression = array (); + private $groupByExpression = null; /** The ORDER expression */ private $orderExpression = array (); @@ -1930,6 +1930,8 @@ class dblayeroo $groupBy = array (); if ($this->joinObject) $full = true; + if ($this->groupByExpression === null) + return null; foreach ($this->groupByExpression as $pos=>$o) { if ($full !== false) @@ -1941,7 +1943,11 @@ class dblayeroo if ($this->joinObject) { foreach ($this->joinObject as $obj) - $groupBy = array_merge ($groupBy, $obj->groupByGet (true)); + { + $ext = $obj->groupByGet (true); + if ($ext !== null) + $groupBy = array_merge ($groupBy, $obj->groupByGet (true)); + } } ksort ($groupBy, SORT_NATURAL); return $groupBy; @@ -2064,7 +2070,7 @@ class dblayeroo $sql .= "\n WHERE ". implode (" ", $whereGetExpression); $groupByExpression = $this->groupByGet (); if (! empty ($groupByExpression)) - $sql .= "\n GROUP BY ". implode (" ", $groupByExpression); + $sql .= "\n GROUP BY ". implode (",", $groupByExpression); if (count ($order)) $sql .= "\n ORDER BY ". implode (",", $order); if (! empty ($this->limitExpression))