Search code examples
zend-framework2

orWhere has disappeared in zf2. How to replace it?


Since zf2, orWhere is not possible anymore in query with Zend\Db I found here (ZF2 How to orWhere()) that it is possible to replace it. In my example, there is no 'like', only a query like:

$select->where("....")->orWhere("...")

If using PredicateSet is the only way, how can I use it to make my query?


Solution

  • The easiest way is to use the fluent notation:

    $where = new Zend\Db\Sql\Where;
    $where->OR->equalTo('id', $id);
    

    When in doubt, look through the examples Ralph has posted in his Zend_Db-Examples repository (https://github.com/ralphschindler/Zend_Db-Examples).