Referencing doctrine reference - one to many unidirectional
class User
{
// ...
/**
* @ManyToMany(targetEntity="Phonenumber")
* @JoinTable(name="users_phonenumbers",
* joinColumns={@JoinColumn(name="user_id", referencedColumnName="id")},
* inverseJoinColumns={@JoinColumn(name="phonenumber_id", referencedColumnName="id", unique=true)}
* )
*/
private $phonenumbers;
// ...
}
The part I don't understand is unique=true
. What does it do? The way I read it is ...
- User has a Many to Many relationship with Phonenumber
- it uses the join table
users_phonenumbers
users_phonenumbers.user_id = users.id
users_phonenumbers.phonenumber_id = Phonenumber.id
- and I guess the
unique
does something to constraints a many to many to a many to one relationship somehow. But how do you explain it? Also in a SQL sense (what is the output like)?