Thanks for the reply Dave. Your nested contain example helped me
figure out a way to solve my needs.

I was trying to do a find() on the Album model, when I actually needed
to turn it around and do a find() on Category which contains
Album.active = 1.

$this->Category->contain('Album.active = "1"');
$data = $this->Category->find('all', array( 'conditions' =>
array('Category.id' => 1) ) );

And to get the Images included in each Album:

$data = $this->Category->find('all', array(
                                'conditions' => array('Category.id' => 1),
                                'contain' => array(
                                        'Album' => array(
                                                'Image',
                                                'conditions' => 
array('Album.active' => 1)
                                        )
                                )
                        )
                );

-Corie

On Jul 3, 4:59 pm, DaveMahon <[EMAIL PROTECTED]> wrote:
> Yesterday I started a blog for my CakePHP frustrations and joys. While
> I haven't done any customization and I'll probably murder my future
> PageRank by doing this so early, I posted an article that I think
> might help.
>
> http://lampable.blogspot.com/2008/07/taming-containables-in-cakephp-1...
>
> On Jul 2, 12:07 pm, Corie <[EMAIL PROTECTED]> wrote:
>
> > I'm confused about the new Containable behavior, the missing Bindable
> > behavior and how to do a HABTM find with conditions.
>
> > Here's the set up, simplified.
>
> > Category model
> > habtm => Album
>
> > Album model
> > hasMany = Image
>
> > I want to return all the Albums (Images included) where conditions are
> > Category.id = 1 AND Album.active = 1.
>
> > I've tried going at it different ways without success. Does anyone
> > have a suggestion?
>
> > -Corie
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to