cakephp 同一个表中有两个外键
我有一个使用 CakePHP 的锦标赛网站,我需要在其中管理如下详细信息的条件:
两个竞争对手之间将有一场战斗比赛,我需要管理比赛分组和比赛时间表,这里的竞争对手和对手将是相同的竞争对手表的外键,意味着同一用户将相互反对,在这种情况下,我如何将两个相同的字段(competitor_id)保存到比赛时间表的表中,并且管理员也可以管理竞争对手的订单,如果某个竞争对手是不可用等
I have a tournament website with CakePHP, where i needs to manage a condition like below details:
There will be a fight competition between two competitor's where I needs to manage a match division and match schedules, and here Competitor and Opponent will be the same from the competitor's table's foreign key, means same user will be opposed to each other, than in this case, how can i save two same fields (competitor_id) into the match schedule's table for and admin can also manage, competitor's orders, if some competitor is not available etc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的问题最后变得有点令人困惑,你是否试图简单地从预定的事件和用户(与竞争对手和对手的事件)创建 2 种关系?如果是这样,这可以通过使用外键扩展计划模型中的关系来实现。
而不是说:
您可以展开并设置外键和表名称:
这将为同一模型设置 2 个关系,并且您可以单独保存它们。 进一步阅读。
Your question gets a little confusing towards the end, are you trying to simply create 2 relationships from a scheduled event and users (event with competitor and opponent)? If so, this can be achieved by expanding your relationships in your schedule model with foreign keys.
Instead of say:
You can expand and set the foreign key and table name:
This will setup 2 relationships to the same model, and you can save them separately. Further reading.