KoolReport's Forum

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

PDO Error #2872

Open Andre Van Der Walt opened this topic on on Nov 14, 2022 - 5 comments

Andre Van Der Walt commented on Nov 14, 2022

Good day

I'm getting the following error using the dashboard package.

SQLSTATE[HY000]: General error: 2014 Cannot execute queries while there are pending result sets. Consider unsetting the previous PDOStatement or calling PDOStatement::closeCursor()

Is there a specific setting to fix this?

Sebastian Morales commented on Nov 16, 2022

Would you pls let us know your Dashboad and KoolReport Pro versions as well as your dashboard board/widget code that caused this error? Tks,

Andre Van Der Walt commented on Nov 16, 2022

Hi Sebastian

We are currently on 3.5.0 and 5.16.2 dashboard and pro versions respectively.

We get this on various reports so I'll only supply one example.

Below is the board:

<?php

namespace App\Reports\Report;

use App\Reports\Filters\DateRange;
....

use koolreport\dashboard\containers\Html;
use \koolreport\dashboard\Dashboard;
use \koolreport\dashboard\containers\Row;
use \koolreport\dashboard\containers\Panel;
use koolreport\dashboard\inputs\Dropdown;
use \koolreport\dashboard\widgets\Text;
use \koolreport\dashboard\inputs\Button;
use \koolreport\dashboard\Client;

class QAQuestionsAdherenceBoard extends Dashboard
{
    protected function widgets()
    {
        return [
            Button::create()->text("Back")->onClick(function(){
                return Client::dashboard("Board")->load();
            }),

            Row::create([
                Panel::create()
                    ->header("<b>Filters</b>")
                    ->width(3/3)
                    ->sub([
                        Row::create([
                            [
                                Text::create()->text("<label><strong>Date</strong></label>")->asHtml(true),
                                DateRange::create(),
                            ],
                        ]),

                    ])
            Row::create([
                    ReportTable::create()
                ])->width(2/2),
            ]),
        ];
    }
}

Below is the report:

<?php

namespace App\Reports\Report;

use koolreport\dashboard\fields\Text;
use \koolreport\dashboard\widgets\KWidget;
use Illuminate\Support\Facades\DB;
use \App\Reports\AutoMaker;

class QAQuestionsAdherenceTable extends KWidget
{
    protected function dataSource()
    {
        $dateRange = $this->sibling("DateRange")->value();


        return AutoMaker::rawSQL
        ("
			SELECT....
		");


    }

    protected function onCreated()
    {
        $this
            ->use(\koolreport\datagrid\DataTables::class)
            ->settings([
                "fastRender" => true,
                "plugins" => ["Buttons"],
                "options"=>[
                    "order"=> [
                        [0, 'asc'],
                        [1, 'desc'],
                    ],
                    
                    ],
                    "columnDefs"=>[array(
                        "visible"=> true,
                        "targets"=>0,
                    ),],
                    "searching"=>true,
                    "colReorder"=>true,
                    "fixedHeader"=>false,
                    "responsive"=> true,
                    "select"=>true,
                    "paging"=>true,
                    "autoWidth" => false,
                ],
                "showFooter" => true,
                "columns"=>array(
                    "Column1"=>array(
                        "footerText"=>"<b>Total</b>"
                    )
					....,
                },
                "paging"=>array(
                    "pageSize"=>10,
                ),
                "cssClass"=>array(
                    "table"=>"table table-hover table-grey",
                    "th"=>"table-header-grey"
                ),
            ]);
    }

    protected function fields()
    {
        return [
            Text::create("Column1"),
			.....

        ];
    }

    public function dataView()
    {
        $dataView = parent::dataView();
        $fields = $this->fields();

        return $dataView
            ->fields($fields);
    }
}
Andre Van Der Walt commented on Nov 16, 2022

Also, it does not only occur with Raw queries. We also get this with procedure calls.

Sebastian Morales commented on Nov 17, 2022

Would you pls download the latest koolreport/core version, which is free, and replace your current koolreport/core with it to see if this issue remains? Tks,

Andre Van Der Walt commented on Nov 17, 2022

Hi Sebastian

That seems to have fixed it.

Thank you.

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
solved

Dashboard