Data Processing

Overview #

Data coming from the datasource is piped through various processing nodes until it reaches the data store as final destination.

In the previous section, we learned how to set settings for datasources to connect and pull data from your database or another sources. The data will be then streaming through many processing nodes. Each processing node does a specific task upon the data stream. Together they will help to transform original data into meaningful information/data to be consumed in the report view.

Sample Code #

<?php
use \koolreport\processes\Filter;
use \koolreport\processes\Group;
class MyReport extends \koolreport\KoolReport
{
    ...
    public function setup()
    {
        $this->src('sales')
        ->query("SELECT customerName, productName,region, amount from tblPurchases")
        ->pipe(new Filter(array(
            array("region","=","asia")
        )))
        ->pipe(new Group(array(
            "by"=>"customerName",
            "sum"=>"amount"
        )))
        ->pipe($this->dataStore('sales'));
    }
}

In above example, we want to summarize total purchased amount per customer from Asia region. The data stream from SQL Query will filtered by region then grouped by customerName. In the end, the result of processing will be store in dataStore named "sales".