webCOMAND

query::group_by()

Add one or more fields or expressions to the query GROUP BY clause. The group_by() method takes any number of expression parameters.

Prototype

group_by(mixed $expression, ...): query

Parameters

  • expression - May be:
    • A single string that represents the dot-notation field name.
    • A string that includes an expression.
    • An array where the first element is an array expression and the second is the optional string ASC or DESC to determine the order.

Return

The updated query object is returned.  This is handy for chaining additional methods.

Example

// equivalent to GROUP BY Field
$query->group_by('Field');

// equivalent to GROUP BY Field1, Feild2
$query->group_by('Field1', 'Field2');