views:

33

answers:

1

I have a db with the following tables

user(id, name....)

restaurant(id, name...)

module (id, name )

status_messages(id, pid, message, module_id, ModuleID)

Module Refers to either Users or Restaurant.

Both Users and Restaurants can have status_messages.

When a user (id=21) sets a status message

(1, 1, 'Message', 1, 21)

When a Restaurant (id=3) sets a status message

(2,2, 'Message', 2, 3)

pid = is the self id or parent id for the replies.

Which is the best way to pull out the status message and its replies of a user or a restaurant and display it.

Will i be able to pull it out?

+1  A: 

I think when you are dealing with parents, the Tree behavior is the way to go. The Containable behavior is more used to limit the number of queries done on each page, so you only do the queries you really need. You should take a look at the Tree behavior documentation.

http://book.cakephp.org/view/1339/Tree

jimiyash