db\Query groupBy()

groupBy() public method

Sets the GROUP BY part of the query.

See also addGroupBy().

public $this groupBy ( $columns )
$columns string|array|yii\db\Expression

The columns to be grouped by. Columns can be specified in either a string (e.g. "id, name") or an array (e.g. ['id', 'name']). The method will automatically quote the column names unless a column contains some parenthesis (which means the column contains a DB expression).

Note that if your group-by is an expression containing commas, you should always use an array to represent the group-by information. Otherwise, the method will not be able to correctly determine the group-by columns.

Since version 2.0.7, an yii\db\Expression object can be passed to specify the GROUP BY part explicitly in plain SQL.

return $this

The query object itself

doc_Yii
2016-10-30 16:59:00
Comments
Leave a Comment

Please login to continue.