CakeFest 2024: The Official CakePHP Conference

CollectionFind::groupBy

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

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

説明

public 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();

?>
add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top