Scofield
Scofield

Reputation: 4745

What association I should to use?

I have table something like this (for example, it's Comment model):

id | user_id | text | created | modified

How can I associate this model with User model in CakePHP 2.4?

P.S. Sorry for my english.

Upvotes: 0

Views: 54

Answers (1)

Chris
Chris

Reputation: 429

From your (very) brief description, the relation seems to be "User hasMany Comment" and "Comment belongsTo User".

Usually when in your table you have a column called 'something_id', it means that the model corresponding to this table has a 'belongsTo' relationship with the 'Something' Model. The inverse relationship is hasMany or hasOne depending of the number of instances that 'Something' can be associated with.

For more information you should read some documentation.

Upvotes: 1

Related Questions