Thursday, April 29, 2010

Finds using OR or AND

Hi,

I want to be able to choose if the find should do an AND or OR on a
find using an array but I can't get it to take the same array

The way I have been able to do it is like this:

//AND
$this->Cand->find('list',array(
'conditions' => array('AND' => array('Cand.code_id' => array(38, 49)))
);
//OR
$this->Cand->find('list',array(
'conditions' => array('OR' => array('Cand.code_id' => 38,
'Cand.code_id' => 49,)),
);

But is there a way of doing it like this:

$this->Cand->find('list',array(
'conditions' => array($conditional => array('Cand.code_id' =>$data))
);

Thanks

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: