Do you have?

class Listing extends AppModel {
    public $belongsTo = array('Category');
}

class Category extends AppModel {
    public $hasMay = array('Listing');
}

Then you should be able to:
$listing = $this->Listing->findAll(array('category_id' =>
$category_id));



On Jan 26, 9:30 pm, bob <[EMAIL PROTECTED]> wrote:
> I have a Listings table and another Categories table, and Lists hasMany
> Categories. I am trying to write a cake query where it finds all lists in a
> certain category.
>
> $listings = $this->Listing->findAll(
> array('Category.category_id'=>$category_id)
> );
>
> this returns an error.
>
> Also, if I do $this->Listing->findAll(), it just returns the columns in
> Listings, not Categories. How would i do this?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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