From cfd9f995185c1e943a39dfd987982f34643f822b Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Tue, 25 Jul 2017 09:49:55 +0000 Subject: [PATCH] dblayeroo: manage correctely the GROUP BY when there is join objects git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@3828 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- dblayeroo.php | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/dblayeroo.php b/dblayeroo.php index 441bd64..f78116b 100644 --- a/dblayeroo.php +++ b/dblayeroo.php @@ -1557,8 +1557,6 @@ class dblayeroo if (count ($aliasNames) && count ($aliasNames) !== count ($columnNames)) $this->DBException ( "The number of aliasNames are not the same as the number of columns"); - if ($this->displayColumn === null) - $this->displayColumn = array (); foreach ($columnNames as $nb => $display) { $display = $name = trim ($display); @@ -1576,7 +1574,10 @@ class dblayeroo // expression, if not already done if ($this->groupByExpression === null) { - $this->groupByExpression = $this->displayColumn; + if ($this->displayColumn === null) + $this->groupByExpression = array_keys ($this->fields); + else + $this->groupByExpression = $this->displayColumn; } if ($func === "GROUP_CONCAT" && ($pos = strpos ($name, ",'"))) { @@ -2101,15 +2102,16 @@ class dblayeroo $groupBy = array (); if ($this->joinObject) $full = true; - if ($this->groupByExpression === null) - return null; - foreach ($this->groupByExpression as $pos=>$o) + if (is_array ($this->groupByExpression)) { - if ($full !== false) - $groupBy[$pos] = $this->sep.$this->tableprefix.$this->table.$this->sep. - ".".$o; - else - $groupBy[$pos] = $o; + foreach ($this->groupByExpression as $pos=>$o) + { + if ($full !== false) + $groupBy[$pos] = $this->sep.$this->tableprefix.$this->table.$this->sep + .".".$o; + else + $groupBy[$pos] = $o; + } } if ($this->joinObject) {