It doesn't matter "through" which or how many models you go, it
doesn't change the result.
Which means, the conditions and associations you have defined in
ModelB are being used here, so check those.
On 4 Nov 2008, at 20:07, Ian M. Jones wrote:
>
> Hi all,
>
> I'm a little confused about something I'm seeing with belongsTo
> conditions, and from searching the docs and this list I haven't been
> able to find an answer. Maybe some kind soul can help clear my
> confusion?
>
> In my Crop model I have:
>
> var $belongsTo = array(
> 'EntryClassification' => array('className' => 'Classification',
> 'foreignKey' => 'entry_classification_id',
> 'conditions' => array('EntryClassification.entry' => 1),
> 'fields' => '',
> 'order' => ''
> )
> );
>
> When I do an find operation on a Crop and let it pick up associated
> models I see that the condition is used, a fragment from the where
> clause displayed in the debugger would be like:
>
> LEFT JOIN `classifications` AS `EntryClassification` ON
> (`Crop`.`entry_classification_id` = `EntryClassification`.`id` AND
> `EntryClassification`.`entry` = 1)
>
> However, in my crops_controller I do for a select box:
>
> $entryClassifications = $this->Crop->EntryClassification-
>> find('list');
>
> and it brings back all classifications, not just those that meet the
> "EntryClassification = 1" condition.
>
> This is confirmed in the debugger, I see:
>
> SELECT `EntryClassification`.`id`, `EntryClassification`.`name` FROM
> `classifications` AS `EntryClassification` WHERE 1 = 1
>
> Why is that? Shouldn't a find through the Crop->EntryClassification
> association use the condition?
>
> Thanks for any help in clearing my confusion!
>
> Ian
>
> >
--~--~---------~--~----~------------~-------~--~----~
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