Baz,

Thanks for your quickly answer. By the way, I´ve read your blog. Great
articles!

Going back to my problem...

Beyond making Bob and Tim friends, what I wanna know is what to put in
the Friends table... The IDs of the Users again? Isnt that a useless
repetition? Cant I simply relate the Users in the same table? I think
this issue is beyond I´m using Cake, Ruby or Assembler... It´s a
question of database design, and I´m simply lost... Any brillant idea?

Martin Bavio

On Nov 13, 12:24 am, Baz <[EMAIL PROTECTED]> wrote:
> Hmmmph,
>
> I was wondering that myself. The easy way is to do what's suggested above,
> but duplicate and entry for each relationship:
>
> Eg. When Bob becomes Tim's friend (in the before/afterSave) force and entry
> that makes Tim Bob's friend.
>
> Of you could have one relationship and simply check the "other direction"
> logically in your controllers. But I don't think there are any easy Cake
> answers.
> --
> Baz L
> Web Development 2.0: Web Design, CakePHP, 
> Javascripthttp://www.WebDevelopment2.com/
>
> On Nov 12, 2007 9:14 PM, mbavio <[EMAIL PROTECTED]> wrote:
>
>
>
> > Christopher:
>
> > I understand the basics behind Cake´s HATBM, but I do not understand
> > how to implement here... You have to notice that "Friends" are also
> > "Users", so I dont know how to build the tables. Should I put the same
> > id in both tables? If not, what is the primary key in the "Friends"
> > table?
> > This case is typical in a CMS, where you want to let the user make
> > "friends" in the community. Anybody who has solved this particular
> > problem?
>
> > Thanks.
>
> > On Nov 12, 7:43 pm, "Christopher E. Franklin, Sr."
> > <[EMAIL PROTECTED]> wrote:
> > > Yes, this is a HABTM relationship both ways between friends and
> > > users.  Define the $hasAndBelongsToMany variable at the top of each
> > > model appropriately and then make an extra db table named:
> > > friends_users and within the table, you will have two fields,
> > > friend_id and user_id.
>
> > > After you have a few users and friends, if you want to see a user's
> > > friend of a friend of a friend, you use, the recursive option for the
> > > model:
> > > eg-
> > > $this->User->recursive = 1;
>
> > > The higher you go, the more levels deep will get returned
>
> > > On Nov 12, 2:20 pm, mbavio <[EMAIL PROTECTED]> wrote:
>
> > > > I have a 'User' model, and I want that my Users can have Friends,
> > > > being Friends other Users. Is this a "self HATBM"? How can I solve
> > > > this problem?
>
> > > > 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