public function groupBy($Fields = null)
{
if (is_null($Fields)) {
// Group by every item in the select that isn't a function.
foreach ($this->_Selects as $Alias => $Select) {
if (val('Function', $Select) == '') {
$this->_GroupBys[] = $Select['Field'];
}
}
return $this;
}
if (is_string($Fields)) {
$Fields = explode(',', $Fields);
}
foreach ($Fields as $Field) {
$Field = trim($Field);
if ($Field != '') {
$this->_GroupBys[] = $this->escapeIdentifier($Field);
}
}
return $this;
}