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

Reply via email to