我想要做的映射,這是否:Symfony2中 - 如何構造的id =產品映射
用戶可以擁有多個遊戲。 遊戲可以有多個店主。
我有game
表和game
和ownership
表user
列id
列。我如何連接這些字段?我想要game
和user
字段在ownership
與user
和game
表有關。
我試過OneToMany
和ManyToMany
,但第一個導致生成附加列。我不要想要在game
表中插入任何東西。
- 編輯 - 我@ManyToMany代碼:
/**
* @ORM\ManyToMany(targetEntity="Ownership")
* @ORM\JoinTable(name="ownership",
* joinColumns={JoinColumn(name="user", referencedColumnName="id")},
* inverseJoinColumns={JoinColumn(name="game", referencedColumnName="id")}
* )
*/
它會導致一個錯誤的Symfony的命令行:
[Doctrine\Common\Annotations\AnnotationException]
[Semantical Error] Couldn't find constant JoinColumn, property GameShelf\Us
ersBundle\Entity\User::$ownership.
假設這段代碼在User實體中,targetEntity應該是Game而不是Ownership。試試看。 – Squazic