Jump to main content Jump to doc navigation

xPDOQuery.groupby

Other versions: 3.x — Found a problem? Please edit this page or report an issue.

xPDOQuery::groupby

Add a GROUP BY clause to the query.

Syntax

API Docs: http://api.modx.com/revolution/2.2/db_core_xpdo_om_xpdoquery.class.html#\xPDOQuery::groupby()

xPDOQuery groupby (string $column, [string $direction = ''])

Example

Grab the different 'type's of Boxes with at least one Box of width 15.

$query = $xpdo->newQuery('Box');
$query->where(array(
   'width' => 15,
));
$query->groupby('type');
$boxes = $xpdo->getCollection('Box',$query);

See Also