Doctrine2 では、3 番目のキーを使用して多対多の関係を管理し、複数の同一の関係を追加することができますか?
「Users」テーブルと「Plans」テーブルが 1 つずつあり、2 つの主キー (user_id と plan_id) を持つ user_plan テーブルを生成する通常の多対多の関係を作成しましたが、アプリケーションで同じものを追加できるようにする必要があります。複数回使用する予定です。例: user_plan(generated_id, user_id, plan_id)
現在のユーザーの yml 定義:
Entity\FosUser:
type: entity
table: fos_user
fields:
id:
id: true
type: integer
unsigned: false
nullable: false
generator:
strategy: IDENTITY
manyToMany:
plans:
targetEntity: Plan
inversedBy: users
joinTable:
name: user_plan
joinColumns:
plan_id:
referencedColumnName: id
inverseJoinColumns:
user_id:
referencedColumnName: id
lifecycleCallbacks:
prePersist: [ setUserValue ]
preUpdate: []
私の現在の計画のyml定義:
Entity\Plan:
type: entity
table: plan
fields:
id:
id: true
type: integer
unsigned: false
nullable: false
generator:
strategy: IDENTITY
planName:
type: string
length: 50
fixed: false
nullable: false
column: plan_name
manyToMany:
users:
targetEntity: FosUser
mappedBy: plans
LifecycleCallbacks:
prePersist: [ setCreatedAtValue ]
preUpdate: [ setUpdatedAtValue ]
symfony2でそれが可能かどうか誰かが知っていますか?