小编bra*_*990的帖子

Symfony2 ondelete设置Null

我是symfony2的新手,我开始了一个博客项目.该项目有两个实体,一个是posts(Noticia),另一个是comments(Comentario).我需要删除一个帖子,但我不能因为与评论的关系.

这是我的属性:

/**
 * @ORM\ManyToOne(targetEntity="Noticia", inversedBy="comentarios", onDelete="SET NULL")
 * @ORM\JoinColumn(name="noticia_id", referencedColumnName="id")
 */
private $noticia;
Run Code Online (Sandbox Code Playgroud)
/**
 * @ORM\OneToMany(targetEntity="Comentario", mappedBy="noticia")
 */
private $comentarios = array();
Run Code Online (Sandbox Code Playgroud)

我尝试放,onDelete="SET NULL"但是当我用doctrine更新我的数据库时: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
Run Code Online (Sandbox Code Playgroud)

php constraints foreign-keys symfony symfony-2.5

1
推荐指数
1
解决办法
2204
查看次数

标签 统计

constraints ×1

foreign-keys ×1

php ×1

symfony ×1

symfony-2.5 ×1