【问题标题】:Doctrine2 One-To-Many, Unidirectional with Join Table with data in Join TableDoctrine2 一对多,单向,带连接表,数据在连接表中
【发布时间】:2014-01-15 23:00:43
【问题描述】:

我正在使用 Symfony2,我有这个架构:

Products:
  id
  name
  value

List:
  id
  owner_name
  created_at
  status

我阅读了如何制作 relations with Join Table in Doctrine2 docs 并且一切正常。但是现在,我想在 products_list 表中添加一个字段(状态):

products_list:
  product_id
  list_id
  status

有什么帮助吗?

谢谢:)

【问题讨论】:

    标签: symfony doctrine-orm


    【解决方案1】:

    如果关联应该保持一对多,则必须创建一个第三实体。

    products_list
      product(OneToOne)
      list(ManyToOne)
      status
    
    list:
      products_list(OneToMany)
    
    products:
      products_list(OneToOne)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-11
      • 1970-01-01
      相关资源
      最近更新 更多