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 be nested with one entity_group belonging to another.
1条回答 默认 最新
- dtlrp119999 2011-04-14 03:30关注
So there seems to be two possible solutions based on what you are asking:
- 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.
- 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.
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
- ¥15 Vue3地图和异步函数使用
- ¥15 C++ yoloV5改写遇到的问题
- ¥20 win11修改中文用户名路径
- ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
- ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
- ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
- ¥15 帮我写一个c++工程
- ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
- ¥15 关于smbclient 库的使用