KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Multiple Datastores OneSource #30

Closed Hallie Gromek opened this topic on on Jul 11, 2017 - 2 comments

Hallie Gromek commented on Jul 11, 2017

I can't seem to figure out how to store the data into multiple datastores.

In the below code the Group process is being applied to both, sales and graphsales. I want it only to be applied to be to the sales datastore. Can anyone tell me why?

    $node = $this->src('main')
	->query("SELECT cust_name AS customerName, cust_number, brand_description, yr, ship_date, qtr, gross_dollars AS dollar_sales, quantity_ordered as cases,  prin_name, item_description AS productName FROM new_hist_a 
		WHERE prin_number = :clients AND cust_number = :customers 
				AND 	
                ship_date > :start
                AND
                ship_date < :end
        ")
        ->params(array(
            ":start"=>$this->params["dateRange"][0],
            ":end"=>$this->params["dateRange"][1],
            ":customers"=>$this->params["customers"],
			":clients"=>$this->params["clients"]
        ))
  
    ->pipe(new ColumnMeta(array(
      'dollar_sales'=>array(
        'type' => 'number',
        'prefix' => '$',
      ),
    )))
    ->pipe(new Group(array(
          "by"=>"yr",
           "sum"=>"dollar_sales"
       )))
	->saveTo($node2);
	$node2->pipe($this->dataStore('sales'));  
	
	$node->pipe(new Cube(array(
      "row" => "productName",
      "column" => "yr",
      "sum" => "dollar_sales"
	 )))
	
	->pipe(new RemoveColumn(array(
      "{{all}}"
    )))
	
->saveTo($node2);
 $node2->pipe($this->dataStore('graphsales'));
David Winterburn commented on Jul 12, 2017

Hi Hallie,

Please try changing your code like this:

  $node = $this->src('main')
	->query("SELECT cust_name AS customerName, cust_number, brand_description, yr, ship_date, qtr, gross_dollars AS dollar_sales, quantity_ordered as cases,  prin_name, item_description AS productName FROM new_hist_a 
		WHERE prin_number = :clients AND cust_number = :customers 
				AND 	
                ship_date > :start
                AND
                ship_date < :end
        ")
        ->params(array(
            ":start"=>$this->params["dateRange"][0],
            ":end"=>$this->params["dateRange"][1],
            ":customers"=>$this->params["customers"],
			":clients"=>$this->params["clients"]
        ))
  ->pipe(new ColumnMeta(array(
    'dollar_sales'=>array(
      'type' => 'number',
      'prefix' => '$',
    ),
  )))
  ->saveTo($node2);
    
  $node2->pipe(new Group(array(
    "by"=>"yr",
    "sum"=>"dollar_sales"
  )))
	->pipe($this->dataStore('sales'));  
	
	$node2->pipe(new Cube(array(
    "row" => "productName",
    "column" => "yr",
    "sum" => "dollar_sales"
	)))
	->pipe(new RemoveColumn(array(
    "{{all}}"
  )))
  ->pipe($this->dataStore('graphsales'));

Thanks!

Hallie Gromek commented on Jul 18, 2017

Worked!! Thank you, just a little confusing on how to set up!

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

None