Okey, I'll give it a shot explaining my understanding:

We get used to describing entity relationships via traditional types:
1-to-1, 1-to-many, and many-to many. It would be less confused if we
were able to communicate with cake through these traditional terms.

Cake has its own conventions for describing the relationships (or
associations, to be precise) and it requires we describe the
relationship from the view of the model in question - i.e. to tell how
'this' model relates to 'that' model (as opposed to tell these models
have a certain type of relationship).

Back to your question, with this association defined:
User HasAndBelongsToMany Project
Cake understands that User and Project has many-to-many relationship
(but this relationship is visible only to the User model).
You access the 'users' table via $this->User->somefunction(), and
access the jointable via $this->User->Project->somefunction().
To work with 'projects' table you use $this->Project.

However, Cake won't assume that Project has many-to-many relationship
with Users.
To fully represent the many-to-many relationship we need to define
Project HasAndBelongsToMany User as well.

But, if you don't use $this->Project->User->somefunction() anywhere
you can omit Project HasAndBelongsToMany User. In other words, it's
not
required.

Zonium

On Dec 7, 2:03 pm, powtac <[EMAIL PROTECTED]> wrote:
> Hi zonium,
> a general question: in't it required to set up both "directions"? This
> is something I never understood!
> Simon
>
> On 7 Dez., 22:18, zonium <[EMAIL PROTECTED]> wrote:
>
> > I think your diagram is correct academically.
>
> > For implementation using cake, I  usually just need to specify one of
> > the 2 associations:
>
> > User HasAndBelongsToMany Projects
> > or
> > Projects HasAndBelongsToMany Users
>
> > Because any one of these already represents the linkage between the 2
> > model (User and Project)
>
> > On Dec 7, 11:03 am, Josoroma <[EMAIL PROTECTED]> wrote:
>
> > > You must to copy and paste the url in the 
> > > browser:http://www.sukialogic.com/cakephp/screen_capture/dbdesigner_habtm.png
>
> > > Thanks.
--~--~---------~--~----~------------~-------~--~----~
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