Yes SQL statement with Debug to 2 are ok so I am sure I am doing
something wrong, this data model (this is a short view here) begins to
be complex. Anyway, I will examine everything again, maybe after one
night of good sleep will be better..
Yes everything follows convention, but when I began with Cake I wanted
to test and know a bit more about the associations, I have also used
some stuff from bakery (ie : useModel and so on and I needed to write
a restoreModel..) Anyway I'll keep posting hopefully a "close case"..
PS : my second sample is using real names, I'll apply this in
future :-)
Thanks everyone for your time and help
On Mar 6, 9:06 am, "AD7six" <[EMAIL PROTECTED]> wrote:
> On Mar 6, 8:36 am, "francky06l" <[EMAIL PROTECTED]> wrote:
>
>
>
> > 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.
>
> Why write your associations out like that when everything follows
> convention..? The below is so much easier to read:
>
> model Application
> var $hasMany => array('Company','Applicant');
>
> model Company
> var $hasMany => array('Addr','Financial');
>
> model Applicant
> var $hasMany => array('Addr','Employer');
>
> Does an application really have more than one applicant, and an
> application really have more than one employer? Did you look at the
> executed sql, this seems more like a logic error than anything else. I
> doubt this has anything to do with caching.
>
> Cheers,
>
> AD
> PS. I would change Grants advice from "make up names.." to "use the
> real names!" (as I think/hope you did) at least one person then
> doesn't need to translate stuff to know what it means in reality :)
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---