Couldn't you just create a method in your model which does this, using
Find()?  For example, FindStandard() or FindByType('STANDARD')?  I
believe that's Cake-y, and it keeps your controller lean and your
model fat :)

Ian



On Nov 24, 2:18 pm, villosil <villo...@gmail.com> wrote:
> Hi,
>
> Is there any "Cake-way" to fetch data from associations by a previous
> condition on the main Model? I'll explain myself:
>
> Let's say I have a Product Model, which has a hasMany association with
> an Image Model. The Product has a field called type which defines the
> type of the Product. For example, by the nature of the app, I know
> that only Products that are Product.type='STANDARD' can have images.
> But when i make a find('all) cake always try to fetch the Images for
> every Product.
>
> For performance, it would be better to define, before the find('all'),
> to only apply the association on Products which their type was
> 'STANDARD'.
>
> Internally on a find('all') over an object A, if a hasMany association
> exists with a B Object, cake first gets the data of every A object,
> and then gets for every A object found, the associated B Objects. I
> mean that for what I'm looking for, that information would be there
> before trying to fetch the associated data.
>
> Has someone faced something similar?
>
> Thanks in advance.
>
> Vicent,

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to