KoolReport's Forum

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

How to get mysql set variable into koolreport? #103

Open zenon opened this topic on on Sep 7, 2017 - 6 comments

zenon commented on Sep 7, 2017

Hi KoolReport,

I have a column in my database which contains sql statement to set variable to other sql statements in other columns. Could you please guide me how to get the mysql set variable to generate report?

Appreciate your help.

Thanks a lot.

KoolReport commented on Sep 8, 2017

You do this:

function setup()
{
    $this-src('db')->query("{your query to get the parameters}")
    ->saveTo($params_src)
    ->pipe($this->dataStore('params'));

    $params_src->start();
    //Now you can get the params from dataStore
    $params = $this->dataStore("params")->data();
    //The $params is an array of associate array containing your parameters
    //Now you can continue to get your real query
     
    $this->src('db')->query("{Your real query}")
    ->params(array(
        ":myparam"=>$params[0]["name_of_param"]
    ))
    ->pipe($this->dataStore('results'));
}

Hope that helps.

zenon commented on Sep 12, 2017

tried the above but got an error: undefined offset:0

->params(array(

    ":myparam"=>$params[0]["@Date"]
))

@Date is in the set variable. Did I do this correctly?

Appreciate your help.

Thanks.

zenon commented on Sep 13, 2017

Hi KoolReport,

I have tried the above, the report can be generated, however, it resulted in an error: undefined offset:0.

Could you please guide me with this?

Thank you very much,

KoolReport commented on Sep 13, 2017

Hi, I have tested this case and it works well. The issue could be:

  1. {your query to get the parameters} is not correct
  2. The query return empty data.
zenon commented on Sep 13, 2017

I have checked through and yes, the query return empty data. However, I have already fixed this problem.

Thank you so much.

KoolReport commented on Sep 13, 2017

Great!

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