How to create sql OR WHERE condition in Zend Framework 2

As far as you probably know in ZF2 there is no “orWhere()” metod anymore.

In that case creating “OR WHERE” condition is a little bit tricky, but still doable without writing pure SQL code.
We will make use of so called Predicates

$select = new Select();

// This is where the magic happens
new Predicate\PredicateSet(
new Predicate\Operator(‘first_field’, Predicate\Operator::OPERATOR_EQUAL_TO, $value1),
new Predicate\Operator(‘second_field’, Predicate\Operator::OPERATOR_EQUAL_TO, $value2),

That’s it! You can use couple of different types from Operator properties like “Operator::OPERATOR_GREATER_THAN” or “Operator::OPERATOR_LESS_THAN”.