> I am trying to find posts within a category that are associated with a
> category. Right now, I have this:
>
> $this->set('posts', $this->Category->Post->find('all', array('conditions' =>
> array('Category.uri' => $uri))));
>
> But this doesn't seem to work. An error is showing this:
>
> Warning (512): SQL Error: 1054: Unknown column 'Category.uri' in 'where
> clause' [CORE/cake/libs/model/datasources/dbo_source.php, line 684]
You could instead fetch the Category and have Cake include its Posts.
$this->Category->find(
'first',
array(
'conditions' => array(
'Category.uri' => $uri
),
'recursive' => 1
)
);
Or:
$this->Category->find(
'first',
array(
'conditions' => array(
'Category.uri' => $uri
),
'contain' => array('Post')
)
);
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:
Post a Comment