I different string values komma separated out of a form.
In the code I cast them and then it looks like this:
$kritkeyword ='test, abc, xyz';
Now I want to use the variable within an IN-function. In original sql ist would be:
where keyword IN ('test', 'abc', 'xyz')
In my code I tried to do the following:
$select->where('keyword IN (?)', $kritkeyword);
I also tried:
$select->where(['keyword IN ?' =>$kritkeyword]);
Until now I had different ideas how to write it, but I always get a sql error. So how to do this correct?
You must use Zend\Db\Sql\Where. If $kitkeyword
is array :
$condition = new Zend\Db\Sql\Where();
$condition->in('keyword', $kritkeyword);
$select->where($condition);