KoolReport's Forum

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

How to correct use data() #645

Closed Eugene opened this topic on on Feb 2, 2019 - 11 comments

Eugene commented on Feb 2, 2019

Hi,

if I have a dataStore with more than one column what is the correct way to get only one from the dataStore For example to use in the sentence like this

$params[":selectedItems"] = $this->dataStore('subquery')->data........

Regards, Eugene

KoolReport commented on Feb 2, 2019

If you want to get a new datastore with only one selected column you use only(). if you want to get the whole values of a column in array, you use pluck().

Eugene commented on Feb 2, 2019

thanks

Eugene commented on Feb 2, 2019

Sorry, but what could be the reason if I get the empty array with pluck()

I check Datastore - I created test Table

with following

Table::create(array(
            "dataStore" => $this->dataStore('subquery'),
        ));

i get the table

but this $this->dataStore('subquery')->pluck('id') returns array ()

KoolReport commented on Feb 2, 2019

I've tested again and seems pluck() is working well. If possible, please help prepare a case on your server with the issue. Please send us the link and the testing code to our support email.

Eugene commented on Feb 2, 2019

Oh, it looks again like a kind of interference - when I deleted everything around preparing the test file it works ok....

So now I will try to find what is wrong in the full version... thanks

Eugene commented on Feb 2, 2019

My case looks like this now: Print_r in this code in setup() function return Array()

$this->src('quinos')
            ->query($subquery)
            ->pipe($this->dataStore('subquery'));
        Print_r($this->dataStore('subquery')->pluck('id'));

But the same line Print_r($this->dataStore('subquery')->pluck('id')); in the view file works ok

KoolReport commented on Feb 2, 2019

One thing: Data is not available yet in the setup(). You setup the data pipe but there is no data yet until you call run() function. The reason why the dataStore('subquery') is working at the view is because the report is run before render.

Eugene commented on Feb 2, 2019

Hm... but my idea was to use the result of the query in another query.... So I would like to use something like $params[":selectedItems"] = $this->dataStore('subquery')->pluck('id')); and use :selectedItems as a parameter in another sql query How to organize it?

KoolReport commented on Feb 2, 2019

Ok then, you use this:

$this->src('quinos')
            ->query($subquery)
            ->pipe($this->dataStore('subquery'))
            ->requestDataSending();

Now your dataStore subquery has data available.

Eugene commented on Feb 2, 2019

Oh.... i met it somewhere at the forum already..... but too much info can not remember everything. I think I need "Koolreport: missing manual" :-))

Thank you.

KoolReport commented on Feb 2, 2019

Yeah I showed you in the issue of how to get data in the defaultParamValues() to get all selected values for BSelect :)

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
solved

None