【发布时间】:2015-10-07 11:42:30
【问题描述】:
我想创建一个通知系统。有一个Notification 类。一个通知可以分配给多个用户,而不仅仅是一个。
有一个联合表user_notifications,有两列:user_id和notification_id
用户类中$notifications的定义是这样的:
/**
* @ManyToMany(targetEntity="Notification")
* @JoinTable(name="user_notifications",
* joinColumns={@JoinColumn(name="user_id", referencedColumnName="id")},
* inverseJoinColumns={@JoinColumn(name="notification_id", referencedColumnName="id", unique=true)}
* )
**/
private $notifications;
一切正常。但是我想在user_notifications 表中添加一个新列,如果给定用户读取了通知,我想将其存储在该表中。我应该如何在 Doctrine2 中管理它?
【问题讨论】:
标签: php symfony doctrine-orm doctrine