Thursday, June 25, 2009

Re: Containable grabbing too much data

You don't show:
var $actsAs = array('Containable');

On Jun 25, 11:59 pm, Miles J <mileswjohn...@gmail.com> wrote:
> So I know how to use containable really well, but this is being weird.
> Its pulling ALL relations, even when I limit it with containable.
> Heres my models.
>
> class ArticleFavorite extends AppModel {
>         var $belongsTo = array('User', 'Article');
>
> }
>
> class Article extends AppModel {
>         var $belongsTo = array('User', 'Game');
>
>         var $hasMany = array(
>                 'Favorites' => array(
>                         'className' => 'ArticleFavorite',
>                         'dependent' => true,
>                         'exclusive' => true
>                 ),
>                 'Comments' => array(
>                         'className' => 'CommentsArticle',
>                         'foreignKey' => 'item_id',
>                         'dependent' => true,
>                         'exclusive' => true
>                 )
>         );
>
>         var $hasAndBelongsToMany = array('Tag');
>
> }
>
> And heres my pagination that's causing the problem. Im paging on the
> ArticleFavorite model and containing the Article and then containging
> the User of the Article. BUT I am getting all the Articles
> associations instead of just User.
>
> 'ArticleFavorite' => array(
>         'conditions' => array('Article.status' => 'published',
> 'Article.viewAccess' => 'public'),
>         'order' => array('ArticleFavorite.created' => 'DESC'),
>         'contain' => array('Article' => array('User'))
> )
>
> Any idea why Game, Tag, Favorites and Comments are being returned? Its
> causing way too many queries.
--~--~---------~--~----~------------~-------~--~----~
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: