Nop, it doesn't work.
As i understand, belongsTo will create a join table in sql.
However, in this case,
an equipment can belongs to a school or an area, but not both
On Feb 8, 1:37 am, "RichardAtHome" <[EMAIL PROTECTED]> wrote:
> If I'm understanding correctly:
>
> You will need to set up two associations:
>
> in model equipment:
>
> $belongsTo = array('school', 'area');
>
> (make sure the school and area arguments above appear in the same
> order as their school_id and area_id in the table)
>
> On a related note, I'm not sure that's the best schema to represent
> your data and the logic requirements.
>
> On Feb 7, 3:19 am, "exiang" <[EMAIL PROTECTED]> wrote:
>
> > Here is the scenario:
>
> > 1)
> > An Area have many schools
> > A school belongs to an area
>
> > 2)
> > A school have many equipments
> > An area have many equipments too
> > Thus, an equipment can belongs to either a school or an area (as in
> > belongs to the office of the area that govern all school)
>
> > 3)
> > i have db table and models for area, school and equipment
>
> > 4)
> > when an equipment belongs to a school, its area_id field will marked 0
> > when an equipment belongs to an area, its school_id field will marked
> > 0
>
> > How can i define the belongsTo in Equipment class to work in my
> > requirement?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---