Sorry for the bad references, actually is use hasMany relation in both
cases for the foreign model. So basically :

model Application
     var $hasMany => array('Company' => array('className' =>
'Company',
 
'foreignKey' => 'application_id'),
                               array('Applicant' => array('className'
=> 'Applicant',
 
'foreignKey' => 'application_id));

model Company
    var $hasMany => array('Addr' => array('className' => 'Addr',
 
'foreignKey' =>  'company_id'),
                                     'Financial' => array('className'
=> 'Financial',
 
'foreignKey' => 'company_id));

model Applicant
   var $hasMany => array('Addr' => array('className' => 'Addr',
 
'foreignKey' => 'applicant_id),
                                     'Employer' => array('className'
=> 'Employer',
 
'foreignKey' => 'applicant_id));

You can see above that the model Addr has relation with Company and
Applicant, in case of Company the applicant_id is set to 0, and
company_id is set to 0 in case of an Applicant. The problem I have is
when I use findAll on the top level (ie : Application), I do not
retreive the Addr for the applicants (but I retreive the Employers).
I think this has to do with the fact that Addr is queried also for the
Company ... I guess it has to do with caching somehow, but could not
really digg in it.
As I said I never retreive a Company or an Applicant using the Addr,
so for me then the belongsTo is not the "best" solution..

I hope this is a bit clearer...
Thanks


On Mar 6, 12:05 am, "Grant Cox" <[EMAIL PROTECTED]> wrote:
> In future, don't refer to all of your models as "model" - make up
> names like User, Group, Student, School, whatever you like, just so we
> can follow what you are saying easier :)
>
> I am guessing the problem is that one of your models has multiple
> associations to the same foreign model, and the problem is that you
> don't have different keys for these associations.  ie instead of
> var $belongsTo = array(
>         'Parent' => array('className' => 'Parent', 'foreignKey' =>
> 'modelx_id'),
>         'Parent' => array('className' => 'Parent', 'foreignKey' =>
> 'modely_id'),
> );
> have
> var $belongsTo = array(
>         'Father' => array('className' => 'Parent', 'foreignKey' =>
> 'modelx_id'),
>         'Mother' => array('className' => 'Parent', 'foreignKey' =>
> 'modely_id'),
> );
>
> This will keep two associations to the Parent model, but will be
> indexed under "Mother" and "Father" respectively.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to