Monday, August 20, 2012

Re: Multiple Database relations (HABTM and HasMany)?

I won't write out the models (too tired), but I'll give you the DB structure and you can base the models off that:
Table: users
id (primary key)
username
pass

Table: tasks
id (primary key)
user_id  <--- This is the user that created the task

Table users_tasks
id (primary key)
user_id
task_id

This way, given a certain task you can find the creator and all of the people assigned to the task. 

On Sunday, August 19, 2012 8:50:52 PM UTC-4, InJu wrote:
Hi everybody,

this my first time working with CakePHP and my first big PHO project as well.

I want to build the Model associations between a User and Task database. Every user has many tasks and a task can be linked to many users. As I understand HABTM-Relations this should be one. But I also want to save the User who created the task. This is a hasMany relation. My question is now, how does the models for Users and Tasks look like?

Thanks in advance!

--
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.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate