KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to get some simple CRUD done with doctrine 2 but when it's time to update a record with one property set as an array collection I don't seem to get removeElement() to work as it's supposed to. I even tried doing it in this ridiculously ugly way: foreach($entity->getCountries() as $c) { $entity->getCountries()->removeElement($c); $this->em->persist($entity); $this->em->flush(); } and it didn't work... Anyone knows how to handle this? I've asked for a solution to this in many different forms and haven't got a good response so far... seems there's lack of good examples of Doctrine 2 CRUD handling. I'll post more code at request. Edit //in user entity /** * * @param \Doctring\Common\Collections\Collection $property * @OneToMany(targetEntity="Countries",mappedBy="user", cascade={"persist", "remove"}) */ private $countries; //in countries entity /** * * @var User * @ManyToOne(targetEntity="User", inversedBy="id") * @JoinColumns({ * @JoinColumn(name="user_id", referencedColumnName="id") * }) */ private $user;
Tags (comma-separated)
Save Edits
Cancel