To retrieve ANY of the results with any of the id's, just call:
$data = array(38,48);
$this->Cand->find('list',array(
'conditions' => array('Cand.code_id' =>$data)
);

Otherwise, if you want all of them, you can call a count() with the
same conditions to see how many rows it returns and then compare with
your id's array size.
If they both have the same size, means that all id's were retrieved
(considering that id is a primary key or, at least, a unique index)

hope this help!
Lucca Mordente

On 29 abr, 10:28, slippy <handle...@gmail.com> wrote:
> I want to be able to pass an array of id's into a find and also
> specify if the results found should contain all of the id's or any of
> them.
>
> Thanks
>
> Alex
>
> On 29 Apr, 12:04, "Dr. Loboto" <drlob...@gmail.com> wrote:
>
>
>
>
>
> > 'Cand.code_id' => $data provides Cand.code_id IN (1, 2, 3) that is
> > equivalent to Cand.code_id = 1 OR Cand.code_id = 2 OR Cand.code_id =
> > 3. So there is no need in OR. Query like "Cand.code_id = 1 AND
> > Cand.code_id = 2 AND Cand.code_id = 3" is useless. So there is no need
> > in AND. So what do you want?
>
> > On Apr 29, 3:39 pm, slippy <handle...@gmail.com> wrote:
>
> > > 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 sitehttp://cakeqs.organdhelpothers 
> > > 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+unsubscr...@googlegroups.com For more options, visit this group 
> > > athttp://groups.google.com/group/cake-php?hl=en
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp 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+unsubscr...@googlegroups.com For more options, visit this group 
> > athttp://groups.google.com/group/cake-php?hl=en
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organd 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+unsubscr...@googlegroups.com For more options, visit this group 
> athttp://groups.google.com/group/cake-php?hl=en

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to