I have 3 tables:
- Activities
- Posts
- Comments
Activities has two attributes: item_id
and item_type
. Attribute item_type
specifies if it is a post or a comment and item_id
contains the id of the respective type. Comments are also linked to posts. I need to sort my activities according to post created time.
Now since activities can be linked to posts or comments, how can I define the association of such kind and write a query in cake php?
EDIT:
The attributes relevant to this question are as follows
Activities: item_id, item_type
Posts: id, created
Comments: id, post_id