开发者

Groups of groups in cakephp

I'm attempting to find out if there is a cake convention for handling groups belonging to other groups. I have a HABTM relationship between the tables 'entities' and 'entity_groups', but then entity_groups can also开发者_JAVA技巧 be nested with one entity_group belonging to another.


So there seems to be two possible solutions based on what you are asking:

  1. http://book.cakephp.org/view/1339/Tree - CakePHP has a Tree Behavior, for a listing items that are part of another item of the same Model, ie, think of nested lists. CarTypes is a model, SUV is a CarType, SUV Model is a CarType that's in the sub-category of SUV, and thus related to SUV.
  2. http://book.cakephp.org/view/1650/hasMany-through-The-Join-Model Modifying your entity_groups model to operate it as a hasMany relationship to both entities and groups, and link it to a ParentGroup. So each entity_group relationship has a ParentGroup model that enables you to create your own tree like structure for the models.

The best solution is to probably do a combination of these, use the hasMany to modify the Join model and add the Tree Behavior rather than trying to roll your own.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜