@ManyToMany 与连接表中其他字段的关联

发布于 2024-12-10 11:42:28 字数 90 浏览 0 评论 0原文

在Symfony2下,如何管理与连接表中附加字段的多对多关联?

例如,我想知道哪个人何时使用马。用户和马具有多对多关联,我们存储该用户骑那匹马的日期。

Under Symfony2, how to manage a Many-to-many association with additional fields in the joining table ?

For instance, I want to know which person uses a horse, and when. User and Horse have a many-to-many association and we store the date when this user rides that horse.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

单挑你×的.吻 2024-12-17 11:42:28

如果联接表不仅仅是一个联接表,而且实际上包含其他列,那么您不再拥有 ManyToMany,而是两个 OneToMany 关联:

  • 一个人有很多次骑行,
  • 一匹马有很多次骑行,
  • 一个骑行有一个
  • 人骑有一匹马

If the join table is more than just a join table, and in fact contains additional columns, than you don't have a ManyToMany anymore, but two OneToMany associations :

  • a person has many rides
  • a horse has many rides
  • a ride has one person
  • a ride has one horse
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文