Group

Introduction #

Group process acts like the GROUP BY statement in SQL Query.

Sample Code #

Group by single column #

<?php
<?php
use \koolreport\processes\Group;
class MyReport extends \koolreport\KoolReport
{
    public function setup()
    {
        ...
        ->pipe(new Group(array(
            "by"=>"country",
            "sum"=>"polulation"
        )))
        ...
    }
}

Group by multiple columns #

<?php
<?php
use \koolreport\processes\Group;
class MyReport extends \koolreport\KoolReport
{
    public function setup()
    {
        ...
        ->pipe(new Group(array(
            "by"=>array("country","state"),
            "sum"=>array("polulation","income")
        )))
        ...
    }
}

Properties #

Nametypedefaultdescriptionexample
bystring/arrayList of columns to be group"by"=>array("country,state")
sumstring/arrayList of columns to be sum"sum"=>"population"
avgstring/arrayList of columns to be averaged"avg"=>"income"
minstring/arrayList of columns to get min value"min"=>"income"
maxstring/arrayList of columns to get max value"avg"=>"max"
countstring/arrayList of columns to get count value"count"=>"customer"
sortbooltrueWhether to sort data in grouped columns"sort"=>false