Jonathan Franks wrote: > my code... > > $c = New Criteria; > > $criterion = $c->getNewCriterion(ItemPeer::PUBLISHED, 1); > > $criterion->addAnd($c->getNewCriterion(ItemPeer::SOLD, 0)); > > $c->add($criterion); > > $c->addOr(ItemPeer::GOANTIQUES, 1); > > $this->items = FeedPeer::doSelectFeed($c, null, 'GoAntiquesItem'); > > > I'm expecting .... > > ..... WHERE (holloware_item.PUBLISHED=1 AND holloware_item.SOLD=0) *OR* > holloware_item.GOANTIQUES=1 > > but I'm getting ... > > ..... WHERE (holloware_item.PUBLISHED=1 AND holloware_item.SOLD=0) *AND* > holloware_item.GOANTIQUES=1 > > Can anyone see my mistake?? > > > > > > > It is not a mistake but how propel works. I also thought that writing code like yours I will get an OR but $c->addOr() is when you want to include a rule about the same database field. By default $c->add() will overwrite the previous rules if the first argument (the table field) is the same, thus $c->addOr will make an OR statement for this field. The same is true for $c->addAnd() but you thought it works correct because by default it uses AND between fields, but the purpose of $c->addAnd is when you define different criteria for the same field and you want them connected with and AND. Also why are you using Criterion object directly? Your code can look like:
$c = new Criteria(); $c->add(ItemPeer::PUBLISHED, 1); $c->add($c->getNewCriterion(ItemPeer::SOLD, 0) $c->add(ItemPeer::GOANTIQUES, 1); $this->items = FeedPeer::doSelectFeed($c, null, 'GoAntiquesItem'); The code above will achive the same results. Now, to answer your quest, I faced this problem some time ago but do not remember if I found I work around or found a right way to do it so I hope somebody else can give you the right way to achieve that. Kupo --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~----------~----~----~----~------~----~------~--~---