So I have little problem, I have code like this:
$query = $repository->createQueryBuilder('p')->
where('p.kalorie <= :kalorie AND p.cena <= :kwota AND p.deser = :sniadanie')->
setParameters(array(
'kalorie' => $kalorie,
'kwota' => $kwota,
'sniadanie' => 1))->getQuery();
$wynik = $query->getResult();
But I want to do something like:
if id = 1 then 'kwota' => $kwota + 20
if id = 2 then 'kwota' => $kwota + 55
if id = n then 'kwota' => $kwota + x
I mean something like:
SELECT * FROM Recipe WHERE (id = $id AND kwota < ($kwota + 20)) OR (id = $id2 AND kwota < ($kwota + 55)) OR (id = $idN AND kwota < ($kwota + x))
If it's about your SQL query, you can use the 'expr' class : http://doctrine-orm.readthedocs.org/en/latest/reference/query-builder.html#the-expr-class
If it's about php variable you can use a ternary operator :