groupBy()

groupBy($field, $override = false)

Groups a set of results based in one common param
@param String $field
@param Boolean $override
@return PhpBURN_Core

Params


$field
Defined param to group the set of results, it can be a field from model or even a param into the database

$override (opcional)
That will clear all previous $model->groupBy() setted options and start again with this new one.

Explanation


This will group your results based on a param, it can be a field, a function into the database, a set of fields, etc…

Usualy you will use this method with a COUNT or others database functions.

Default Usage


$user = new Users();

$user->select('name','name');
$user->select('COUNT(id_users)','total');

$user->groupBy('name');

while($user->fetch()) {
         $string = sprintf("There are %s entries for %s name", $user->total, $user->name);
         print $string;
}