KoolReport's Forum

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

If a MultiSelect field is empty then SQL-Where condition SELECT LIKE % #81

Open bysystem opened this topic on on Aug 17, 2017 - 2 comments

bysystem commented on Aug 17, 2017

Dear support team,

I'm stucking on the following problem:

  • The user keeps on the frontend one of the MultiSelect fields empty and fires.
  • My SQL statement in setup() has several AND concatenations with those MultiSelect params with WHERE IN (:param)...
  • How do I implement the WHERE condition for a MultiSelect field with empty selection by the user so in that case ALL the options are piped into the SQL statement?

Any hint for me?

Kind regards

KoolReport commented on Aug 19, 2017

Make a simple if statement, if the param is empty, run $empty_params_sql, if not run the $param_sql. Or you can construct an query base on the conditions:

$sql = "select ... ";
if(count($this->params)>0)
{
    $sql.="where column in (:in)";
}

Hope that helps.

bysystem commented on Aug 21, 2017

It works excellent! Thx a lot for your hint!!!

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