Add the GROUP BY part in the SQL request
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@3632 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
@@ -1918,6 +1918,36 @@ class dblayeroo
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/** Get the GROUP BY fields defined. If a joinObject is set with GROUP BY
|
||||
* statement, return the joinObject order with its tableprefix/name in
|
||||
* addition of the ones of this object
|
||||
* If the parameter $full is set, add the table prefix/name to the result
|
||||
* @param boolean|null $full Add the table prefix/name if set
|
||||
*/
|
||||
public function groupByGet ($full=false)
|
||||
/* {{{ */
|
||||
{
|
||||
$groupBy = array ();
|
||||
if ($this->joinObject)
|
||||
$full = true;
|
||||
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)
|
||||
{
|
||||
foreach ($this->joinObject as $obj)
|
||||
$groupBy = array_merge ($groupBy, $obj->groupByGet (true));
|
||||
}
|
||||
ksort ($groupBy, SORT_NATURAL);
|
||||
return $groupBy;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/** Define a LIMIT for the request.
|
||||
* To use only the nbLines, put a 0 on startLine
|
||||
* @param integer $startLine The starting line in the result list
|
||||
@@ -2026,10 +2056,15 @@ class dblayeroo
|
||||
$order = $this->orderGet (false);
|
||||
$sql .= " $displayColumns\n FROM $this->sep$this->tableprefix".
|
||||
"$this->table$this->sep";
|
||||
$sql .= "\n ".$this->joinsGet ();
|
||||
$joinsExpression = $this->joinsGet ();
|
||||
if ($joinsExpression !== "")
|
||||
$sql .= "\n ".$this->joinsGet ();
|
||||
$whereGetExpression = $this->whereGetExpression ();
|
||||
if (! empty ($whereGetExpression))
|
||||
$sql .= "\n WHERE ". implode (" ", $whereGetExpression);
|
||||
$groupByExpression = $this->groupByGet ();
|
||||
if (! empty ($groupByExpression))
|
||||
$sql .= "\n GROUP BY ". implode (" ", $groupByExpression);
|
||||
if (count ($order))
|
||||
$sql .= "\n ORDER BY ". implode (",", $order);
|
||||
if (! empty ($this->limitExpression))
|
||||
@@ -2358,7 +2393,7 @@ class dblayeroo
|
||||
{
|
||||
if (! array_key_exists ($column, $setValues))
|
||||
{
|
||||
if (array_key_exists (0, $resUpdate))
|
||||
if ($update !== false && array_key_exists (0, $resUpdate))
|
||||
{
|
||||
// In UPDATE, if a column is not modified (doesn't appears in
|
||||
// setValues), use the old value to search
|
||||
|
||||
Reference in New Issue
Block a user