Thursday, April 2, 2009

filtering with the containable behavior

I am trying to filter with the containable behavior:

$favs = $this->VideoItemFavorite->find('all', array(
'conditions' => array(
'VideoItemFavorite.user_id' => Configure::read('user_id')
),
//'limit' => 3,
'contain' => array(
'VideoItem.video_list_id = ' . $vl_id,
'VideoItem.Video'
)
));

The (undesirable) result of this query is to deliver all VideoItemFavorite records that match the find condition. For all matches returned, if VideoItem.video_list_id = $vl_id, then VideoItem.Video is included in the array. If VideoItem.video_list_id != $vl_id, I still get VideoItemFavorite (which is not wanted), but no VideoItem.Video.

What I would like to happen:

Deliver VideoItemFavorite records only if the associated VideoItem.video_list_id = $vl_id.

It's not valid, but this is how I'd like to write the query:

$favs = $this->VideoItemFavorite->find('all', array(
'conditions' => array(
'VideoItemFavorite.user_id' => Configure::read('user_id'),
'VideoItemFavorite.VideoItem.video_list_id' => $vl_id
),
//'limit' => 3,
'contain' => array('VideoItem.Video')
));

Can someone please clue me in on a workable way to get that result?
--
View this message in context: http://n2.nabble.com/filtering-with-the-containable-behavior-tp2578823p2578823.html
Sent from the CakePHP mailing list archive at Nabble.com.


--~--~---------~--~----~------------~-------~--~----~
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: