PivotSQL process
When working with large SQL datasets, it might be faster using PivotSQL
process instead of Pivot
one. PivotSQL
utilizes your SQL database to aggregate result instead of looping and aggregating with PHP:
//MyReport.php
$this->src('automaker')
->query('select * from customer_product_dollarsales2')
->pipe(new \koolreport\pivot\processes\PivotSQL([
"column" => "orderYear",
"row" => "customerName",
"aggregates"=>array(
"sum"=>"dollar_sales",
),
]))
->pipe($this->dataStore('pivotData'));
It should be noted that PHP's session must be turned on at the beginning of your app or page for PivotSQL
to work. The reason is because PivotSQL
stores aggregated reults in session to save processing time:
session_start();
Another note is that initially PivotSQL
only aggregates data for the first row field and column field. Thus, if you have more than one row field or column field it's advisable to use PivotMatrix
widget to show PivotSQL
data:
//MyReport.view.php
\koolreport\pivot\widgets\PivotMatrix::create(array(
"id" => "pivotMatrix1",
'dataSource' => $this->dataStore('pivotData'),
));
Get started with KoolReport
KoolReport will help you to construct good php data report by gathering your data from multiple sources, transforming them into valuable insights, and finally visualizing them in stunning charts and graphs.