KoolReport's Forum

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

Plan on using Stored Procedure to populate datastore. #1593

Open Richb201 opened this topic on on Aug 23, 2020 - 5 comments

Richb201 commented on Aug 23, 2020

Here is what I am planning. Let me know if you think that it will work? I will create a stored procedure that will create a temporary table from scratch that has the exact columns that I need for my graphs. Once the Stored procedure ends, I will pipe the temporary table into D3 for display, using php. Notice that I am NOT returning the results set from the stored procedure. Any chance of this working?

David Winterburn commented on Aug 24, 2020

As long as you can run your Stored Procedure before querying the temporary table I think it would be fine. Just try it and let us know if you have any difficulty. Thanks!

Richb201 commented on Aug 25, 2020

After spending a bunch of time on it in the last few days, I am becoming jaded with the lack of tools to write (and debug) stored procedures. In your examples you create the data stores in setup(), and then use these to create reports directly in the php/html code. Is there any advantages to creating the data stores in setup, rather than directly in the php code prior to populating the report?

KoolReport commented on Aug 26, 2020

Creating the data pipe line at setup() or directly write SQL at view file is totally your choice. You can choose the way that is most suitable. We suggest to create dataStore at setup() because of flexibility and the principle of seperation between logic layer and view layer. If you setup the datastore in the main class, you can render the report with different views with the same data. In our example of generate pdf, we have 2 views, one for web and one for pdf, building the dataStore at setup() will give us shorter code and flexibility of rendering multiple view.

Hope my explanation helps.

Richb201 commented on Aug 26, 2020

Thanks. I have an issue where I am creating the same datastore twice. Here is the sql:

//create threeway title RA
        $sql="
        SELECT e.employee, e.employee_title, e.w2_wages, risk, 
             CASE 
                 WHEN risk='low' THEN  w2_wages
                 WHEN risk='medium' THEN  w2_wages*.5
                 ELSE 0
              END as qualified
        FROM employees as e, titles as t
        WHERE e.email='$email' AND e.campaign='$campaign' 
        AND t.email='$email' AND t.campaign='$campaign'
        AND e.employee_title=t.title
        ORDER BY e.employee
        ";
        $this->src('substantiator')
            ->query($sql)
            ->pipe($this->dataStore("Three Way Risk Analysis"));

This seems to work fine to export to Excel. But then when I run it again (in a separate setup), this time to create a table I get nothing:

Table::create(array(

"dataStore"=>$this->dataStore("Three Way Risk Analysis"),
"class"=>array(
    "table"=>"table table-hover"
)

));

Any obvious reason that this is not working?

David Winterburn commented on Aug 27, 2020

Hi Richard,

Please post your full report's setup and view souce code an a separated topic for us to check it for you. Thanks!

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
None yet

None