koolphp / koolreport

This is an Open Source PHP Reporting Framework which you can use to write perfect data reports or to construct awesome dashboards using PHP
https://www.koolreport.com/
MIT License
226 stars 66 forks source link

Undefined index filtering empty result #18

Open BernhardK91 opened 5 years ago

BernhardK91 commented 5 years ago

Hi there,

I am getting the following error:

Undefined index: DIFFERENZ (View: C:\[...]\resources\views\dashboard\fieldsales.blade.php)

The result of the SQL-query is empty and the problem is occured in the following line:

"dataSource" => $this->dataStore("customer.flop100.annualComparison")->filter('DIFFERENZ', '<', 0),

Thank you in advance!

BernhardK91 commented 5 years ago

I solved my problem with this workaround:

if ($this->dataStore("customer.flop100.annualComparison")->count() > 0) {
    Table::create([
        [...]
    ]);
} else {
    echo '<i>no results</i>';
}
koolphp commented 5 years ago

That's great. The Table actually detect the empty rows of datastore however the issue lies inside the filter() function which have problem if result is empty. May be it is better to return the datastore itself if there is no data.