« CollectionFind::fields
CollectionFind::having »

CollectionFind::groupBy

(No version information available, might only be in Git)

CollectionFind::groupBy — グループ化の条件を設定する

説明

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

この関数は、結果セットをひとつまたはそれ以上のカラムによってグループ化するのに使えます。 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();

?>
関連キーワード:
CollectionFind   グループ   groupBy   mysql   xdevapi   条件   カラム   sort   expr   coll   Collection   fields   information   available   セット   以上   集約   操作   Assuming   valid   Extract   documents   group   results   find
関連する関数・ページ:
mysql-xdevapi-collectionfind.having   class.mysql-xdevapi-collectionfind   mysql-xdevapi-collectionfind.fields   mysql-xdevapi-collectionfind.construct   mysql-xdevapi-collectionfind.sort   mysql-xdevapi-collectionfind.lockshared