Skip to content

Instantly share code, notes, and snippets.

@jerson
Created April 17, 2017 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jerson/12de6532c9486b9d791f8e71516884a5 to your computer and use it in GitHub Desktop.
Save jerson/12de6532c9486b9d791f8e71516884a5 to your computer and use it in GitHub Desktop.
<?php
/** @Entity */
class User
{
// ...
/**
* Many User have Many Phonenumbers.
* @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;
public function __construct()
{
$this->phonenumbers = new \Doctrine\Common\Collections\ArrayCollection();
}
// ...
}
/** @Entity */
class Phonenumber
{
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment