Last active
December 17, 2015 02:59
-
-
Save oste/5540302 to your computer and use it in GitHub Desktop.
remove all relating entities from entity
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
$post = $postManager->findOneBy(['id' => $id]); | |
//each post has many categories | |
//how can I remove any existing relationships from the rel table? | |
$post->removeCategories(); |
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
/** | |
* @ORM\Table(name="post") | |
* @ORM\Entity | |
*/ | |
class Post | |
{ | |
/** | |
* @ORM\ManyToMany(targetEntity="Category", inversedBy="posts") | |
* @ORM\JoinTable(name="post_categories_rel") | |
*/ | |
protected $categories; | |
public function __construct() | |
{ | |
$this->categories = new ArrayCollection(); | |
} | |
public function removeCategories() | |
{ | |
//how should this look? | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment