KoolReport's Forum

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

If condition before Filter Process #1308

Closed hsw opened this topic on on Feb 19, 2020 - 3 comments

hsw commented on Feb 19, 2020

Hi, How do perform if else statement in the setup function?

I tried to insert if else statement before using the Filter process. I encountered error "array_merge(): Argument #1 is not an array in ..../Table.php".

Example of my setup() function:

$type = $this->params["type"];

if ($type = "A") 
{  $pid = "1";  }
else
{  $pid = "2";  }

$this->src('products')
        ->pipe(new Filter(array(
            array("id","=",$pid),
	    array("active_flag","=","Y"),
	    array("eligible","contain",$sts)
        )))
KoolReport commented on Feb 19, 2020

It should be

if ($type == "A")
... 

The way you do is correct. May be you can try to set

if ($type == "A") 
{  $pid = 1;  }
else
{  $pid = 2;  }

What I mean is you use the number instead of string.

hsw commented on Feb 20, 2020

Thanks for your advice. It's working fine now.

KoolReport commented on Feb 20, 2020

That's great!

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

None