I want to create a rather complex and flexible query with Doctrines Criteria
. I have an andWhere
that is included in every query, but then (depending on input) I want to add some optinal parameters with orWhere
.
$criteria = Criteria::create();
/* Add Criteria for last 55 Days (every query) */
$criteria->where(Criteria::expr()->gte('gameCreation', $long));
/* Gather optional Params */
$orxList = array();
/* Optional Criteria */
if (!empty($champions)) {
foreach ($champions as $c) {
$orxList[] = Criteria::expr()->eq('champion',$c);
}
}
...
$criteria->andWhere(Criteria::expr()->orX($orxList));
This leads to an Exception:
No expression given to CompositeExpression.
How would I combine such a Criteria with the initial where
clause?