I’m trying to define multiple criteria for a single field in symfony, but every time I define a second criterion, it overwrites the previous one. Here is an example of my code:
# build query to fetch search results $c = new Criteria(); # set minimum price if($request->getPostParameter('price_from') > 0) { $c->add(HomeModelPeer::PRICE, $request->getPostParameter('price_from'), Criteria::GREATER_EQUAL); } # set maximum price if($request->getPostParameter('price_to') > 0) { $c->add(HomeModelPeer::PRICE, $request->getPostParameter('price_to'), Criteria::LESS_EQUAL); }
Is there a way to define more than one per field?
For the case where you have both limits, you need to do something like this: