【发布时间】:2015-07-26 23:00:42
【问题描述】:
我是 symfony2 的新手,我开始了一个博客项目。该项目有两个实体,一个是帖子 (Noticia),另一个是 cmets (Comentario)。
我需要删除一个帖子,但我不能因为与 cmets 的关系。
这是我的属性:
/**
* @ORM\ManyToOne(targetEntity="Noticia", inversedBy="comentarios", onDelete="SET NULL")
* @ORM\JoinColumn(name="noticia_id", referencedColumnName="id")
*/
private $noticia;
/**
* @ORM\OneToMany(targetEntity="Comentario", mappedBy="noticia")
*/
private $comentarios = array();
我尝试输入 onDelete="SET NULL" 但是,当我使用学说更新我的数据库时:php app/console doctrine:schema:update --force 我收到了这个错误:
The annotation @ORM\ManyToOne declared on property Noticia
Bundle\Entity\Comentario\::$noticia does not have a property named "onDelete".
Avaible properties: targetEntity, cascade, fetch, inversedBy
【问题讨论】:
标签: php symfony foreign-keys constraints symfony-2.5