KoolReport's Forum

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

Problem in binding parameter logic in PdoDataSource (and possibly other datasources/queries) #119

Open ashbike opened this topic on on Sep 26, 2017 - 5 comments

ashbike commented on Sep 26, 2017

Try to write a setup function like this:

 public function settings() {
  // other code        
        return array(
            "dataSources" => array(
                "my_datasource1" => array(
                    "connectionString" => $connectionString,
                    "username" => "mydbuser",
                    "password" => $db_password,
                    "charset" => "utf8"
                )
            )
        );
    }

 public function setup() {
        $this->src('my_datasource1')
                ->query("SELECT a, b, c, username from xyztable") // username is a field in my table which I want to show
                ->pipe($this->dataStore('my_store1'));
    }

It will silently fail. At Least I do not see any error in PHP error log with E_ALL. It tries to replace the 'username' with database username declared in function settings()... The query it finally tries to execute is: SELECT a, b, c, 'mydbuser' from xyztable. Same happens if you query has these strings: connectionString or password or charset.

Now rewrite as follows:

public function setup() {
        $this->src('my_datasource1')
                ->query("SELECT a, b, c, username from xyztable") // username is a field in my table which I want to show
                ->params([])               
                ->pipe($this->dataStore('my_store1'));
    }

It will start working! Passing an empty params array reinstantiates the $params array being used in these DataSources (protected function bindParams($query,$params)) to replace query params.

HTH,

KoolReport commented on Sep 27, 2017

You are right. It should not behave like this. We will fix today.

KoolReport commented on Sep 27, 2017

Dear ashbike,

Thank you very much for letting us know this bug. FYI, We have released KoolReport version 1.61.5 containing the fixes for this bug. The fix applies to PDODataSource, MySQLDataSource and SQLSRVDataSource.

Again thank you very much.

KoolPHP Inc

ashbike commented on Sep 27, 2017

You welcome. Thanks to you for this nifty, developer friendly reporting library. Great stuff!!!

Robert commented on Sep 27, 2017

The thing I love the most in koolreport team is their fast response and problem-solving orientation. Bug in software is unavoidable but how fast you response matters. Keep it up your good work.

BTW, I really like your recent blog post, it made me laugh so much.

ashbike commented on Sep 28, 2017

Just saw the blog post. It's hilarious!

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
bug
solved

None