KoolReport's Forum

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

SimpleCard with mysql datastore #930

Open benoit opened this topic on on Jun 17, 2019 - 2 comments

benoit commented on Jun 17, 2019

Hi koolreport,

Actualy, I use SimpleCard with a mysql datasource like this

 <?php
    SimpleCard::create(array(
        "title"=>"Revenue",
         "value"=>$this->src("automaker")->query("select sum(amount) from payments"),
         "preset"=>"success",
         "format"=>array(
             "value"=>array(
             "prefix"=>"$"
                )
            ),
         "cssClass"=>array(
             "icon"=>"fa fa-dollar",
            ),
        ));
        ?>

I would like to use a datastore in stead of a datasource.

Is it possible? Do you have an example?

KoolReport commented on Jun 17, 2019

Sure, if you your datastore has an amount column and you want to show the sum, you do:

SimpleCard::create(array(
    "value"=>$this->dataStore("mystore")->sum("amount")
    ...
));

or if you want to get a value from a row:

SimpleCard::create(array(
    "value"=>$this->dataStore("mystore")->get(0,"amount"); // get amount of row 0
    ...
));
benoit commented on Jun 17, 2019

Great! thank you for the support.

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