Mam takie zapytanie:
$qb = $em->createQueryBuilder(); $qb->select('c') ->from('SzypiBundle:Cars', 'c') ->where('c.price >= :pricefrom') ->andWhere('c.price <= :priceend') ->andWhere('c.year >= :yearfrom') ->andWhere('c.year <= :yearto') ->andwhere('c.enginetype LIKE :enginetype') ->andwhere('c.model LIKE :model') ->andwhere('c.mark LIKE :mark') ->andwhere('c.enginea = :enginea') ->andwhere('c.engineb = :engineb') 'priceto' => ($request->request->get('form')['priceto']), 'yearfrom' => ($request->request->get('form')['yearfrom']), 'yearto' => ($request->request->get('form')['yearto']),));
I teraz pytanie. Jak ominąć jedną z funkcji andWhere jeśli jakaś wartość z formularza jest pusta?
czyli jeśli w formularzu nie jest podany model auta to żeby jakoś ominać tą funkcje:
->andwhere('c.model LIKE :model').
Mam nadzieje, że dobrze wyjaśniłem.