Thanks, Jeremy. I'll give that a try, although I'm not sure it will
help in this case. I'm working with a legacy DB schema and all of the
tables have a deleted_at column. I want only the data where this value
is 0. If Cake is ignoring the conditions in the one instance, I'm not
sure it'll pay any attention to those of the other model. Perhaps
there's something else I'm missing.

On Sun, Jun 17, 2012 at 11:26 PM, Jeremy Burns | Class Outfit
<jeremybu...@classoutfit.com> wrote:
> I hope I'm not missing the point here, but what I do is have a vanilla 
> $belongsTo/$hasMany/whatever that has no conditions and is called the same as 
> the remote model. Then I set up alternatives that include the conditions and 
> are named appropriately and are used when needed, for example:
>
> public $belongsTo = array(
>        'Project' => array(
>                'className' => 'Project',
>                'foreignKey' => 'project_id'
>        ),
>        'ActiveProject' => array(
>                'className' => 'Project',
>                'foreignKey' => 'project_id',
>                'conditions' => array('Project.active' => '1')
>        )
> );
>
> Jeremy Burns
> Class Outfit
>
> http://www.classoutfit.com
>
> On 17 Jun 2012, at 00:01:19, lowpass wrote:
>
>> From the fine manual:
>>
>> conditions: an array of find() compatible conditions or SQL strings
>> such as array('User.active' => true)
>>
>> It doesn't appear to be used, however.
>>
>> public $belongsTo = array(
>>       'Project' => array(
>>               'className' => 'Project',
>>               'foreignKey' => 'project_id',
>>               'conditions' => array('Project.deleted_at' => '0')
>>       )
>> );
>>
>> Project model:
>>
>> public $hasMany = array(
>>       'Expression' => array(
>>               'className' => 'Expression',
>>               'foreignKey' => 'project_id',
>>               'conditions' => array('Project.deleted_at' => '0'),
>>               'dependent' => true
>>       )
>> );
>>
>> I know I can include it in the find() array but it would be nice not
>> to have to include it each time. I presume that's why it's available
>> here.
>>
>> I see that 'conditions' is not dealt with in
>> Model::_generateAssociation() method. Has anyone seen this working?
>>
>> --
>> Our newest site for the community: CakePHP Video Tutorials 
>> http://tv.cakephp.org
>> Check out the new CakePHP Questions site http://ask.cakephp.org and help 
>> others with their CakePHP related questions.
>>
>>
>> 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
>
> --
> Our newest site for the community: CakePHP Video Tutorials 
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help 
> others with their CakePHP related questions.
>
>
> 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

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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

Reply via email to