简体   繁体   English

Cake PHP中同一个表的多个外键?

[英]Multiple foreign keys to the same table in Cake PHP?

Cake has its conventions for automating some functionality interaction between it's models and the tables they reference. Cake有自己的惯例,可以自动化它的模型和它们引用的表之间的某些功能交互。 Foreign keys should be called people_id, if they reference a table called people. 外键应该称为people_id,如果它们引用名为people的表。 How do I handle a case where a row holds two people, and needs foreign keys for both people? 如何处理一行中有两个人,并且两个人都需要外键的情况? It's obvious that I can't duplicate the column names, having two people_id columns. 很明显,我不能复制列名,有两个people_id列。

Consider a competition where you have two competitors. 考虑一个有两个竞争对手的竞赛。 Each competitor is represented by a row in the competitor's table. 每个参赛者在竞争对手的桌子上排成一排。 The competitions table needs to refer to both of those competitors. 比赛表需要参考这两个竞争者。 How can I do this wouldn't breaking the automatic functionality that Cake offers? 我怎么能这样做不会破坏Cake提供的自动功能?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM