I have 2 entities Item and Itemimage. The relationship between Item to Itemimage is OneToMany Unidirectional with JoinColumn. I took help from doctrine documentation. The OneToMany unidirectional with JoinColumn is achieved with the ManyToMany Annotation:
/**
* @ManyToMany(targetEntity="Itemimage")
* @JoinTable(name="itemimage",
* joinColumns={@JoinColumn(name="item_id", referencedColumnName="id")},
* inverseJoinColumns={@JoinColumn(name="image_id", referencedColumnName="itemid")}
* )
*/
Where:
- image_id: itemid is a property in the Itemimage Entity
- item_id: is the primary key property of the Item Entity
I made a property $images in Item Entity and gave it the above docblock. The problem is that when I tried updating the schema. I get a doctrine error: “The Table ‘itemimage’ already exists“. I’m sure that is not the case. I have no idea what to do.
Please help me with this.
Thanks! I appreciate your help.
It is supposed to be:
leading to the creation of a third table (itemimage_map) that will contain just the mapping of the other two tables. It is not an existing table you have to join there. That table will contain item_id and image_id which are the primary keys of tables you want to map.