I am completely unfamiliar with the Doctrine, so please tell me about me.
In my simplest case, I have a class "User" and "Category", a user can belong to several categories, defined as such
class Application_Model_User { public function __construct() { $this->userCategory = new ArrayCollection(); } } private $userCategory; public function getUserCategories() { return $this->userCategory; } }
Adding a category to a user is very simple, but I cannot understand or see from the document how I delete certain relationships ... For example, if I did
$thing = $em->getRepository('Application_Model_User'); $result = $thing->findOneBy(array( 'id' => (int) 5 )); foreach($result->getUserCategories() as $category) { if($category->getName() == 'Another Sub Cat') {
I could be able to delete the link, if I delete the object with the deletion, is the entire category deleted? any tips appreciated!
source share