Last active
December 18, 2015 03:48
-
-
Save Chrysweel/5720254 to your computer and use it in GitHub Desktop.
Relation Many to Many, Artist - Event. One artist can to be a lot of events, and Event can to have a lot of artist.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I want to recuperate events of one artist. | |
My entity event: | |
/** | |
* @ORM\ManyToMany(targetEntity="myproject\ArtisaBundle\Entity\Artist", inversedBy="events") | |
* @ORM\JoinTable(name="events_artists") | |
**/ | |
protected $artists; | |
public function setArtists($artists){ | |
$this->artists = $artists; | |
} | |
public function addArtists(\myproject\ArtistBundle\Entity\Artist $artist) | |
{ | |
$this->artists[] = $artist; | |
} | |
public function getArtists(){ | |
return $this->artists; | |
} | |
public function __construct() { | |
$this->artists = new \Doctrine\Common\Collections\ArrayCollection(); | |
} | |
My entity artist: | |
/** | |
* @ORM\ManyToMany(targetEntity="myproject\MyBundle\Entity\Event", mappedBy="artists") | |
*/ | |
protected $events; | |
public function __construct() { | |
$this->events = new \Doctrine\Common\Collections\ArrayCollection(); | |
} | |
Now I want to from my repository, recuperate , the events of artist. | |
How could I do it ? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Before with a relation onetomany I can to do:
But now ??