KoolReport's Forum

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

Can you tell me what this koolreport error means? #1603

Open Richb201 opened this topic on on Aug 29, 2020 - 8 comments

Richb201 commented on Aug 29, 2020

Type: Error

Message: Call to a member function execute() on boolean

Filename: /app/vendor/koolreport/core/src/datasources/MySQLDataSource.php

Line Number: 384

Tracing through the code I see this is the source of the problem: $stmt = $this->prepareAndBind($query, $searchParams); << $stmt is false and this is why $stmt->execute() is failing $stmt->execute();

Richb201 commented on Aug 30, 2020

The problem is this second line $stmt = $this->prepareAndBind($query, $searchParams);
$stmt->execute(); //line 384

$searchParams[] is empty. $stmt is false because that is being returned by prepareAndBind(). I think it should be a structure. Is this a known bug?

$stmt = $this->connection->prepare($query);

Here is the value of query that is causing prepare() to fail.

    SELECT e.employee, e.employee_title, e.w2_wages as wages,  t.risk, 
         CASE 
             WHEN risk='low' THEN  e.w2_wages
             WHEN risk='medium' THEN  e.w2_wages*.5
             ELSE 0
          END as QREs 
    FROM employees as e, titles as t
    WHERE e.email='richb201@gmail.com' AND e.campaign= 'Apple'  
    AND t.email='richb201@gmail.com' AND t.campaign= 'Apple' 
    AND e.employee_title=t.title
    ORDER BY e.employee
    

Is it possible that the query is just too long? I think that this query was working a day or two ago. Please advise?

David Winterburn commented on Aug 31, 2020

Hi Richard,

This looks like a query grammar error so mysqli connection can't prepare a statement from it. I would suggest the following steps:

  1. Create a mysqli connection yourself, says its name is $conn.
  2. Run this command to see if it returns a correct statement:
$stmt = $conn->prepare($query);
var_dump($stmt);

If it doesn't please modify your query till it's correct. Let us know the result. Thanks!

Richb201 commented on Aug 31, 2020

Ok. I'll give it a try. The actual buffer above came out of the debugger. The SQL seems good. Btw, another module that uses Koolr also gives the same error. That one had not been modified. This is the reason I think this may be not an application error but a system issue. That SQL statement was working fine.

How should I 'create a mysqli yourself'? My application creates $this->db and uses it. But $this in the MyReport is different from the $this I use in my application.

I have three "reports"; MyDashboard, MyReport, and My ExportExcel. Each has its own settings() and setup(). MyDashboard (which runs at startup) seems to work fine still.

David Winterburn commented on Sep 1, 2020

You could create a database connection yourself and don't have to depend totally on your framework.

https://www.php.net/manual/en/function.mysqli-connect.php

If you test your query ok but the report still has error please post your report's setup code for us to check it for you. Thanks!

Richb201 commented on Sep 1, 2020

David, can you tell me where in koolreport_pro-4.7.1 I can find an example of a simple koolreport table report that you know works? I'd like to trade out my MyReport and replace it with your example.This will prove whether it is an application problem or something deeper.

David Winterburn commented on Sep 2, 2020
Richb201 commented on Sep 2, 2020

Solved. Somehow my connection string was set to go to a different database than I use. I have no idea how this happened since I don't have such database name.

One more quick question. I have two piecharts that are generated by

PieChart::create(array(
    "title"=>"Number of employees",
    "dataSource"=>$this->dataStore("titles_pie"),
    "columns"=>array("title","employee_count")
)
);
PieChart::create(array(
        "title"=>"Number of employees",
        "dataSource"=>$this->dataStore("titles_pie"),
        "columns"=>array("title","employee_count")
)
);

Can I get these two to appear side by side?

David Winterburn commented on Sep 3, 2020

Just put the charts in your CSS framework's grid system. For example, if you use Bootstrap there's a grid system with row and column.

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