Doctrine ORM Criteria - dynamic orX
criteria, doctrine, doctrine-orm, orm, php
Solution
You can call it dynamicly like this:
$criteria = new Criteria();
$expr = array();
$expr[] = $criteria->expr()->eq(/** what you want */);
$expr[] = $criteria->expr()->contains(/** what you want */);
$criteria->where(call_user_func_array(array( $criteria->expr(), 'orX' ),$expr));
Problem
I spent a long time on that but can't find proper solution. How to amend code below so I could use a variable number of dynamic contains conditions? ``` $criteria = Criteria::create(); $expr = Criteria::expr(); $criteria->where( $expr->orX( $expr->contains('field1', $str), $expr->contains('field2', $str), $expr->contains('field3', $str), $expr->contains('field4', $str) ) ); ```