开发者

Cakephp Containable or Tree?

开发者 https://www.devze.com 2023-01-19 19:42 出处:网络
I have a db with the following tables user(id, name....) restaurant(id, name...) module (id, name ) status_messages(i开发者_Go百科d, pid, message, module_id, ModuleID)

I have a db with the following tables

user(id, name....)

restaurant(id, name...)

module (id, name )

status_messages(i开发者_Go百科d, 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?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消