Adding having() support to the Fluent query builder.
Signed-off-by: Ben Corlett <bencorlett@me.com>
This commit is contained in:
@@ -19,7 +19,7 @@ class Grammar extends \Laravel\Database\Grammar {
|
||||
*/
|
||||
protected $components = array(
|
||||
'aggregate', 'selects', 'from', 'joins', 'wheres',
|
||||
'groupings', 'orderings', 'limit', 'offset',
|
||||
'groupings', 'havings', 'orderings', 'limit', 'offset',
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -286,6 +286,24 @@ class Grammar extends \Laravel\Database\Grammar {
|
||||
return 'GROUP BY '.$this->columnize($query->groupings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile the HAVING clause for a query.
|
||||
*
|
||||
* @param Query $query
|
||||
* @return string
|
||||
*/
|
||||
protected function havings(Query $query)
|
||||
{
|
||||
if (is_null($query->havings)) return '';
|
||||
|
||||
foreach ($query->havings as $having)
|
||||
{
|
||||
$sql[] = 'AND '.$this->wrap($having['column']).' '.$having['operator'].' '.$this->parameter($having['value']);
|
||||
}
|
||||
|
||||
return 'HAVING '.preg_replace('/AND /', '', implode(' ', $sql), 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile the ORDER BY clause for a query.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user