mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 17:21:39 +09:00
Parse GROUP BY and HAVING clauses
This commit is contained in:
parent
db13d110b8
commit
bc287b0e0f
1 changed files with 24 additions and 0 deletions
|
|
@ -151,6 +151,30 @@ class Query extends VariableBase
|
|||
}
|
||||
|
||||
// Compose the GROUP BY clause.
|
||||
if ($this->groupby && count($this->groupby->columns))
|
||||
{
|
||||
$columns = array();
|
||||
foreach ($this->groupby->columns as $column_name)
|
||||
{
|
||||
if (preg_match('/^[a-z0-9_]+(?:\.[a-z0-9_]+)*$/', $column_name))
|
||||
{
|
||||
$columns[] = self::quoteName($column_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
$columns[] = $column_name;
|
||||
}
|
||||
}
|
||||
$result .= ' GROUP BY ' . implode(', ', $columns);
|
||||
}
|
||||
if ($this->groupby && count($this->groupby->having))
|
||||
{
|
||||
$having = $this->_arrangeConditions($this->groupby->having);
|
||||
if ($having !== '')
|
||||
{
|
||||
$result .= ' HAVING ' . $having;
|
||||
}
|
||||
}
|
||||
|
||||
// Compose the LIMIT clause.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue