A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2009 yearMutliple criteria for single field in symfony? - page 1
User InfoPosts
Mutliple criteria for single field in symfony?#1
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?

posted date: 2009-04-10 10:57:00


Re: Mutliple criteria for single field in symfony?#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2009-04-10 10:57:01


Re: Mutliple criteria for single field in symfony?#3
For the case where you have both limits, you need to do something like this:$c = new Criteria();$c2 = $c->getNewCriterion(HomeModelPeer::PRICE, $request->getPostParameter((price_from(), Criteria::GREATER_EQUAL);$c2->addAnd($c->getNewCriterion(HomeModelPeer::PRICE, $request->getPostParameter((price_to(), Criteria::LESS_EQUAL) );$c->add($c2);

posted date: 2009-04-10 11:12:00


Re: Mutliple criteria for single field in symfony?#4
Thank you. This is exactly what I was looking for.

posted date: 2009-04-10 11:21:00


select page: « 1 »
Copyright ©2008-2017 www.momige.com, all rights reserved.