dblayeroo: manage the group by of the join object is defining the GROUP BY without not groupbed by field. (ex. Join with display MAX only field)

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@3831 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2017-07-25 12:10:19 +00:00
parent 20befc4fcf
commit 3509b8b1f3

View File

@@ -1577,6 +1577,12 @@ class dblayeroo
// expression, if not already done
if ($this->groupByExpression === null)
{
// Set to empty array to demonstrate that a GROUP BY is needed, but
// there is no already defined displayed Columns.
// Used if the group by is called from join object
if ($this->displayColumn === null)
$this->groupByExpression = array ();
else
$this->groupByExpression = $this->displayColumn;
}
if ($func === "GROUP_CONCAT" && ($pos = strpos ($name, ",'")))
@@ -2099,11 +2105,35 @@ class dblayeroo
public function groupByGet ($full=false)
/* {{{ */
{
$groupBy = array ();
$groupBy = null;
if ($this->joinObject)
$full = true;
if ($this->joinObject)
{
foreach ($this->joinObject as $obj)
{
$ext = $obj->groupByGet (true);
if ($ext !== null)
{
if (! is_array ($groupBy))
$groupBy = array ();
$groupBy = array_merge ($groupBy, $ext);
}
}
}
// If there is some GROUP BY in join Object, but not in this object, all
// the displayed fields must be added to be added in the GROUP BY
if (is_array ($groupBy) &&
(is_null ($this->groupByExpression) ||
(is_array ($this->groupByExpression) &&
empty ($this->groupByExpression))
))
$this->groupByExpression = $this->displayColumn;
if (is_array ($this->groupByExpression))
{
if (! is_array ($groupBy))
$groupBy = array ();
foreach ($this->groupByExpression as $pos=>$o)
{
if ($full !== false)
@@ -2113,16 +2143,8 @@ class dblayeroo
$groupBy[$pos] = $o;
}
}
if ($this->joinObject)
{
foreach ($this->joinObject as $obj)
{
$ext = $obj->groupByGet (true);
if ($ext !== null)
$groupBy = array_merge ($groupBy, $obj->groupByGet (true));
}
}
ksort ($groupBy, SORT_NATURAL);
if (is_array ($groupBy))
ksort ($groupBy, SORT_NATURAL);
return $groupBy;
}
/* }}} */