KoolReport's Forum

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

Input package : Select2 , Invalid parameter number #523

Open Eo Yoonmin opened this topic on on Nov 20, 2018 - 6 comments

Eo Yoonmin commented on Nov 20, 2018
protected function defaultParamValues()
    {
        return array(
            "startDatePicker"=>date("Y-m-d 00:00:00"),
            "endDatePicker"=>date("Y-m-d 23:59:59"),
            "customers"=>array(),
            "fcusts"=>array(),
        );
    }

    protected function bindParamsToInputs()
    {
        return array(
            "startDatePicker",
            "endDatePicker",
            "customers",
            "fcusts",
        );
    }

function setup()
    {
        $query_params = array();
        if($this->params["startDatePicker"]!=array())
        {
            $query_params["start"] =$this->params["startDatePicker"];
        }
        if($this->params["endDatePicker"]!=array())
        {
            $query_params["end"] =$this->params["endDatePicker"];
        }
        if($this->params["customers"]!=array())
        {
            $query_params["customers"] =$this->params["customers"];
        }
        if($this->params["fcusts"]!=array())
        {
            $query_params["fcusts"] =$this->params["fcusts"];
        }

        $this->src('sales')
        ->query("~~~
          WHERE A.write_date BETWEEN date_format(:start,'%Y-%m-%d') AND date_format(:end,'%Y-%m-%d')
            ".
            (($this->params["customers"]!=array())?" AND C.creg_no IN (:customers)":"")
            .
            (($this->params["fcusts"]!=array())?" AND C.fcreg_no IN (:fcusts)":"")
        )
        ->params($query_params)

Hello Great Team!! I'm not goot at English!! The code is the same as above. It will work normally, but if I enter a value in two items(customers, fcusts) as shown below, an error will occur. help me~ thx!!

David Winterburn commented on Nov 20, 2018

Hi Yoonmin,

It seems there're mismatches between the params and their placeholders in the sql query. Please try chaning the params from:

$query_params["start"] = $this->params["startDatePicker"];

to:

$query_params[":start"] = $this->params["startDatePicker"]; //start => :start

Change similarly for other params as well. Then try again and let us know any error message if there is. Thanks!

Eo Yoonmin commented on Nov 21, 2018

Thank you for the reply. I changed the code, but the result is the same. If I select and search the values ​​individually for Select2 [customers] and [fcusts], there is no problem, but if I select and search for both items together, an error occurs.

Show example code that uses two or more Select2 input Package.

Eo Yoonmin commented on Nov 22, 2018

Please give me additional feedback.

Eo Yoonmin commented on Nov 27, 2018

Please, i need answer on this topic. Support is over for this topic? Thanks

KoolReport commented on Nov 27, 2018

Hi, have you change all the params, please post the updated code

Eo Yoonmin commented on Nov 28, 2018

function setup()

{
    $query_params = array();
    if($this->params["startDatePicker"]!=array())
    {
        $query_params[":start"] =$this->params["startDatePicker"];
    }
    if($this->params["endDatePicker"]!=array())
    {
        $query_params[":end"] =$this->params["endDatePicker"];
    }
    if($this->params["customers"]!=array())
    {
        $query_params[":customers"] =$this->params["customers"];
    }
    if($this->params["fcusts"]!=array())
    {
        $query_params[":fcusts"] =$this->params["fcusts"];
    }

    $this->src('sales')
    ->query("~~
      WHERE A.write_date BETWEEN date_format(:start,'%Y-%m-%d') AND date_format(:end,'%Y-%m-%d')
        ".
        ((count($this->params["customers"])>0)?" AND C.creg_no IN (:customers)":"")
        .
        (($this->params["fcusts"]!=array())?" AND C.fcreg_no IN (:fcusts)":"")
    )
    ->params($query_params)

I checked again today and it works well. I updated the version from KoolReport Pro v.2.78.0 to KoolReport Pro v.3.1.0 yesterday and it seems to be affected. Thanks a lot ! :)

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
solved

Inputs