DB::DBAL

The World's Most Powerful Light-Weight DBAL

GroupBy

groupBy( string $group_by_statement )

The groupBy() method allows you to determine how your results are grouped together.

1
DB::MySQL()->table('myTable')->select()->groupBy('column');

You may use multiple groupBy() methods on one query chain, but they will all be used in the query. To remove the GROUP BY clause, use the removeGroupBy() method.

1
2
3
// Query Grouped By column, column2
$stmt = DB::MySQL()->table('myTable')->select()->groupBy('column');
$stmt->groupBy('column2');

removeGroupBy( void )

1
2
3
4
5
6
// Query Grouped By column, column2
$stmt = DB::MySQL()->table('myTable')->select()->groupBy('column');
$stmt->groupBy('column2');
// Query is no longer Grouped:
$stmt->removeGroupBy();