KoolReport's Forum

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

How to get data from dataStore? #14

Open Zubin opened this topic on on May 19, 2017 - 8 comments

Zubin commented on May 19, 2017

I downloaded and tried KoolReport and it's really good reporting tools. I have a question. Is it possible to get raw data from dataStore? I want to create my own things using data.

Peter Williams commented on May 19, 2017

Hi Zubin,

Yes you can! Please use:

$data = $this->dataStore('storename')->data();

The function data() will return the all raw data. If you need the meta data, use the function meta()

$metadata = $this->dataStore('storename')->meta();

Hope that helps.

P.S:Thank you for trying out our product. If you need any further assistance, please let us know

Regards,

Peter

Antonio commented on Jan 1, 2018

Hi,

where must i use that method? In view, I'm trying to use data() but nothing is returned

regards

KoolReport commented on Jan 1, 2018

Hi Antonio,

You need that methods when you want to get processed data from dataStore. Maybe you need them to build custom data display, for example different kind of charts than what are available.

If you did not see any data, there are two reasons:

  1. Really, there is no data
  2. The name input into dataStore() is wrong. There wlll be no error if you insert a wrong name since it will try to create a new and empty dataStore with that name.

Please let us know.

Antonio commented on Jan 1, 2018

Hi, thanks for your answer. I'll give more details now:

this is what I'm doing in MyReport.php

function settings()
    {
        return array(
            "assets" => array(
                "path" => "../../assets",
                "url" => base_url()."/assets",
            ),
            "dataSources" => array(
                "report_data" => array(
                    "class"=>"\koolreport\datasources\ArrayDataSource",
                    "dataFormat"=>"associate",
                    "machine_data"=>$this->params["machine_data"],
                    "measure_data"=>$this->params["measure_data"]


                    #"measure_data"=>$this->params["measure_data"]
                )
            )
        );
    }

    protected function setup() {



        $this->src('report_data')->pipe($this->dataStore("report_data")->data());

    }

I know that there is data, because when, in .view.php file I do this:

$r =
        $this->dataStore("report_data")
;
print_r($r);

I see data, like here:

koolreport\core\DataStore Object (

[dataset:protected] => Array
    (
    )

[params:protected] => 
[report:protected] => Horometerreport Object
    (
        [params:protected] => Array
            (
                [measure_data] => Array
                    (
                        [measure_id] => 67
                        [date] => 2018-01-01
                        [start_at] => 2018-01-01 10:54:26
                        [end_at] => 2018-01-01 10:54:56
                        [starter_horometer] => 554
                        [ending_horometer] => 6
                  

...

But, if a write:

$r =
        $this->dataStore("report_data")->data()
;
print_r($r);

nothing is returned

I'm sure that I'm doing something wrong, but I don't know what.

Regards

KoolReport commented on Jan 1, 2018

There is small mistake in your setup of ArrayDataSource, you should do this:

function setup()
{
    return array(
        "dataSources"=>array(
            "machine_data"=>array(
                "class"=>"\koolreport\datasources\ArrayDataSource",
                "dataFormat"=>"associate",
                "data"=>$this->params["machine_data"],                
            ),
            "measure_data"=>array(
                "class"=>"\koolreport\datasources\ArrayDataSource",
                "dataFormat"=>"associate",
                "data"=>$this->params["measure_data"],                
            ),            
        )
    );
}

There should be a separated data sources for each array.

Antonio commented on Jan 1, 2018

Just wonderful

Thanks!

Antonio commented on Jan 1, 2018

Sorry,

I couldn't pass both arrays. Example:

$this->src('machine_data')->pipe($this->dataStore("machine_data"));
$this->src('measure_data')->pipe($this->dataStore("measure_data"));

regards

Antonio commented on Jan 3, 2018

I solved converting one of data arrays to inside an array. It means: $data = array($weird_data); #where $weird_data is a simple key value array (2D)

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
wiki
help needed

None