Hello there,

I've got four models: User, Gallery, Picture, Comment

Picture got the following relations set in its model.php:

var $belongsTo = array('Gallery', 'User');
var $hasMany = array('Comment' => array('dependent' => true));

I've got a pagination based output of Picture which worked fine until
I wanted to add a filter which should only display Pictures which have
been commented.

$this->paginate = array(
'conditions' => array('Picture.gallery_id' => $id),
fields' => array('Picture.id', 'Picture.title', 'Picture.file',
'User.prename'),
order' => 'Picture.position ASC',
limit' => PAGINATION_PICTURE_LIMIT
);

On trying to add something like 'Comment.picture_id' => $id to the
conditions cake reports that "Comment" does not exist.
I found out that the belongsTo and hasMany associations are fetched
with two separate queries from the db, so of course I cannot work with
the model Comment in the conditions of the pagination.

Is there anything I can do about it?

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 [email protected]
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