CollectionFind::groupBy

グループ化の条件を設定する

説明

public mysql_xdevapi\CollectionFind mysql_xdevapi\CollectionFind::groupBy(string $sort_expr)

この関数は、結果セットをひとつまたはそれ以上のカラムによってグループ化するのに使えます。 COUNT, MAX, MIN, SUM のような集約関数とともによく使います。

パラメータ

sort_expr

グループ化の操作のために使われるカラム。 これは文字列か、カラムをあらわす文字列の配列のうちのどちらかです。

戻り値

その後の処理に使える CollectionFind オブジェクトを返します。

例1 mysql_xdevapi\CollectionFind::groupBy の例

<?php

// Assuming $coll is a valid Collection object

// Extract all the documents from the Collection and group the results by the 'name' field
$res $coll->find()->groupBy('name')->execute();

?>