Doctrine 2:如何使用额外的列来处理连接表 [英] Doctrine 2: How to handle join tables with extra columns

查看:172
本文介绍了Doctrine 2:如何使用额外的列来处理连接表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

解决方案

如何在Doctrine 2中设置带有额外列或多对多关联的连接表? div>

首先,让我解释一下,存在:



连接表也称为交叉表或交叉引用表)是通过主键在同一数据库中将2个(或更多)个其他表连接在一起的表。
这意味着连接表只包含外键,没有这些额外列的位置。



所以当你在这样的表中需要额外的列,它不再仅仅是其他表之间的链接,而是自己成为一个真实的表。



根据Doctrine 2 ,您不再有两个实体之间的多对多关联,而是在3个实体之间获得一对多/多对一关联。



继续阅读这里了解更多详细说明:




How do I setup a join table with extra columns, or a many-to-many association with additional properties, in Doctrine 2?

解决方案

First off, let me explain that this does not exist:

A join table (also known as a junction table or cross-reference table) is a table that links 2 (or more) other tables together within the same database by primary key. This means that a join table will only contain foreign keys, there is no place for these extra columns.

So when you need extra columns in such a table, it is no longer just a "link" between other tables, but becomes a real table on its own!

In terms of Doctrine 2, you no longer have a many-to-many association between 2 entities, but get a one-to-many/many-to-one association between 3 entities.

Continue reading here for more details explanations:

这篇关于Doctrine 2:如何使用额外的列来处理连接表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆