KoolReport's Forum

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

How to add a row in datastore, which is already set. #2513

Open A opened this topic on on Dec 30, 2021 - 3 comments

A commented on Dec 30, 2021

////Query to get users

$query = " select
			pd.pid, pd.sex, pd.DOB, pd.sex_assigned_at_birth, pd.practice_id
			from user_data as pd
			where
				pd.is_active =1 and
				pd.location_id = :location_id 
  ";
// Get Data from DB
		$user = $this->src('test')
			->query($query)
			->params([
				':location_id ' => $this->params['location_id ']
			])
		;

//Using Pivot Group data on age

$user->pipe(new Pivot2D([
			'dimensions' => [
				'row' => 'age',
				'column' => 'sex'
			],
			'aggregates' => [
				'count' => 'age'
			]
		]))->saveTo($test);
/// Saving data to table to render report
$test->pipe($this->dataStore('table1'));

I want to add a row in table1 dataStore. I have tried push method to add row in dataset but it gives me error of undefined index. How can i add row in table1 dataStore?

A commented on Dec 30, 2021

Please let me know if any further detail is required.

Sebastian Morales commented on Dec 30, 2021

There's AppendRow process which appends data rows to the end of a data pipe:

    ->pipe(new \koolreport\processes\AppendRow(array(
        array("column1" => "value1_1",...),
        array("column1" => "value1_2",...),
    )))
    ->pipe(...)

If you wanted to add rows to the beginning or middle we could use Map process.

A commented on Dec 30, 2021

Thank you. Map function worked perfectly as i wanted.

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
solved

None