manyToMany or oneToMany
I have 2 Entites, User and Orders.
There are many users and many orders.
A user can have many orders.
In my Entities I have the following:
Orders.php
/**
*
* @ORM\OneToOne(targetEntity="BM\UserBundle\Entity\User")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
*/
protected $user;
But looking at the db, this creates a user_id field that is unique, so I
can't create anymore orders because the user_id is already in the db.
I know that this is wrong.
Do I need a oneToMany or manyToMany etc relationship so that I can have
multiple orders per user?
Thanks
No comments:
Post a Comment