0

Iam new to Zend Framework 2, and have some trouble to create an WHERE SQL Statement with multiple "OR" clauses.

$ids = array("A1","A2","A3","A4","A5","A6","A7");

foreach ($ids as $id) {
    $select->where->equalTo('id', $id);      
    // how to add OR for remaining ids
}

Is there any simple solution for this case?

2 Answers 2

3

This has worked for me about a month ago. in version 2.2

$ids = array("A1","A2","A3","A4","A5","A6","A7");

$select->where->in('id', $ids);
Sign up to request clarification or add additional context in comments.

1 Comment

Zend is beautiful but tricky and alot of work to know all work arounds
3

You can use the SQL IN operator:

$select->where('id IN (?)', $ids);

1 Comment

FYI this was the ZF1 syntax.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.