Wednesday, October 28, 2009

HABTM relations. How to insert?

Hi.
I have a problem :)

I've got a HABTM relation between Users and Groups.

After linking the models together, I'm having trouble understanding
how to create a new row in the Groups table (from the groups
controller) and, automatically, creating a new record in the
groups_users table. For example:

- when a user creates a new group, he should become a member of that
group as well as the administrator of the same. The administrator is a
boolean field present in the groups_users table.

Also:

- how, after having the id of a Group and an User, can I update the
corresponding row in the join table? Updating the administrator field
for example? (assuming I'm executing all of this From the Group
Controller)

Can someone help me?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: