I'm writing a simple Blog application. I am dealing with two models, BlogPost
and BlogCategory
.
They both have a HABTM relationship to each other using a separate table.
I have written a function in the BlogPost model to load all the posts from a certain category, but it keeps producing a database error.
public function getRecentFromCategory($category, $offset, $limit){
return $this->find('all', array(
'order' => 'BlogPost.date desc',
'offset' => $offset,
'limit' => $limit,
'conditions' => array('BlogCategory.id' => $category)
));
}
Why can't I make a conditional based on the associated categories?