class Lists extends \Entities\AbstractEntity {
/**
* @Id @Column(name="id", type="bigint",length=15)
* @GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ManyToMany(targetEntity="\Entities\Users\Usercomments")
* @JoinColumn(name="id", referencedColumnName="id")
*/
protected $comments;
public function getComments() {
return $this->comments;
}
public function addComments($comment) {
$this->comments->add($comment);
}
public function deleteComments(\Entities\Users\Comments $comments) {
$this->comments->removeElement($comments);
}
/** @PreUpdate */
public function updated() {
//$this->updated_at = new \DateTime("now");
}
public function __construct() {
$this->entry = new \Doctrine\Common\Collections\ArrayCollection();
}
}
У меня есть таблица «многие ко многим», созданная по доктрине. Я могу добавить комментарии к этой таблице:
$getList = $this->_lis->findOneBy((array('userid' => $userid)));
$getComments = $this->_doctrine->getReference('\Entities\Users\Comments', $commentid);
$getList->addComments($getComments);
$this->_doctrine->flush();
но я не могу удалить ...
Я пытался: удалить элемент, но не радость ..
кто-то сказал мне, что я могу удалить что-то в моей коллекции массивов, я не понимаю ...