SuperCube Process

Overview #

Cube process full classname is \koolreport\cube\processes\SuperCube.

The SuperCube is exactly Cube with some added features. In SuperCube process, you could specify multiple fields for rows, multiple fields for columns and multiple fields for each operators. For example:

<?php
use \koolreport\cube\processses\Cube;
class MyReport extends \koolreport\KoolReport
{
    ...
    public function setup()
    {
        $this->src("sales")
        ->query("SELECT country,product,sale from tblPurchases")
        ->pipe(new SuperCube(array(
            "rows" => "productCategory, productName",
            "columns" => "orderYear, orderMonth",
            "sum" => "dollar_sales, tax_amount",
            "sum percent" => "dollar_sales, tax_amount",
            "count" => "dollar_sales, order_id",
            "count percent" => "dollar_sales, order_id",
            "avg" => "dollar_sales",
        )))
        ->pipe($this->dataStore("sales"));
    }
}

The resulted table will look like this:

Product CategoryProduct NameorderYear - 2014 | dollar_sales - sumorderMonth - 12 | order_id - count...
CarCitroen-15CV580,00028...
CarFord Falcon730,00045...
TruckFord F-150480,00032...

Summarized table format #

The summarized table of the SuperCube process includes rows of distinct values of the "row"/"rows" fields (if defined) and columns whose names are in the format of " - | - " or " - {{all}} | - ". Beside those columns there are label columns which are the "row"/"rows" fields and ordered by labels from left to right. Here's an example:

Product CategoryProduct NameorderYear - 2014 | dollar_sales - sumorderYear - {{all}} | dollar_sales - sumorderMonth - 12 | order_id - countorderMonth - {{all}} | order_id - count...
CarCitroen-15CV580,0001,560,0002869...
CarFord Falcon730,0001320,0004582...
TruckFord F-150480,0001730,0003298...