Nate, we love you, stop complaining :)
I think such a FAQ should have a section dedicated to associations !
Here's some :
--------------------
Q. Which model association should I use ?
A. CakePHP offers the following associations to link models together :
"has many", "has one",
"belongs to", "has and belongs to many". These have a clear semantic
meaning, and
you should be able to work out which you need by thinking about what
your models represent :
A city has many roads. A road belongs to a city. A post belongs to an
author. An author has many posts.
An organisation has one president. An organisation has and belongs to
many individuals.
Things worth keeping in mind :
* "has one" is just a special case of "has many" ;
* "belongs to" is the converse of "has many"/"has one" (if "A has many
B" then "B belongs to A")
--------------------
--------------------
Q. I've worked out which associations to use - which table should I
put the association field in ?
A. The easy way is to look at the "has many" relationship. Clearly, if
"A has many B" you don't want
an infinite number of fields in A -- so the field making the
relationship goes in B ("A_id").
"has one" is just a special case of "has many", and "belongs to" is
the converse of "has many" -
so if "D belongs to E", then you put a field "E_id" in D.
--------------------
I'll add some more when I have some time :)
Anselm
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---