级联删除不 working.cascade={"remove"}
Cascade remove not working.cascade={"remove"}
我正在使用 Doctrine 2。我有一个实体,我可以在其中自我加入。连接中的两列是:
/**
* @ORM\ManyToOne(targetEntity="Entities\wall_post", inversedBy="shared_wallpost")
* @ORM\JoinColumn(name="wall_post_id", referencedColumnName="id")
*/
private $shared_from_wallpost;
/**
* @ORM\OneToMany(targetEntity="Entities\wall_post", mappedBy="shared_from_wallpost", cascade={"remove"})
*/
private $shared_wallpost;
Lets say there are two posts: one id = 1001 second id = 1002 ( having
wall_post_id = 1001)
now I want when I delete 1001 , post with wall_post_id 1001 gets
deleted.
为此我使用了 cascade={"remove"} 但它不起作用。
我的删除墙贴对象的查询:
//Removing record from table.
$qb_1 = $em->createQueryBuilder();
$qb_1->delete('\Entities\wall_post', 'wp');
$qb_1->where( 'wp.id = ?1' );
$qb_1->setParameter('1', $wallpost_id );
$qb_1->getQuery()->execute();
$em -> flush();
对于级联={“删除”}
我们必须使用:
$em->remove($wallpost_obj);
$em->flush();
我用过:
$qb_1 = $em->createQueryBuilder();
$qb_1->delete('\Entities\wall_post', 'wp');
$qb_1->where( 'wp.id = ?1' );
$qb_1->setParameter('1', $wallpost_id );
$qb_1->getQuery()->execute();
$em -> flush();
现在级联删除正在运行。
我正在使用 Doctrine 2。我有一个实体,我可以在其中自我加入。连接中的两列是:
/**
* @ORM\ManyToOne(targetEntity="Entities\wall_post", inversedBy="shared_wallpost")
* @ORM\JoinColumn(name="wall_post_id", referencedColumnName="id")
*/
private $shared_from_wallpost;
/**
* @ORM\OneToMany(targetEntity="Entities\wall_post", mappedBy="shared_from_wallpost", cascade={"remove"})
*/
private $shared_wallpost;
Lets say there are two posts: one id = 1001 second id = 1002 ( having wall_post_id = 1001)
now I want when I delete 1001 , post with wall_post_id 1001 gets deleted.
为此我使用了 cascade={"remove"} 但它不起作用。 我的删除墙贴对象的查询:
//Removing record from table.
$qb_1 = $em->createQueryBuilder();
$qb_1->delete('\Entities\wall_post', 'wp');
$qb_1->where( 'wp.id = ?1' );
$qb_1->setParameter('1', $wallpost_id );
$qb_1->getQuery()->execute();
$em -> flush();
对于级联={“删除”} 我们必须使用:
$em->remove($wallpost_obj);
$em->flush();
我用过:
$qb_1 = $em->createQueryBuilder();
$qb_1->delete('\Entities\wall_post', 'wp');
$qb_1->where( 'wp.id = ?1' );
$qb_1->setParameter('1', $wallpost_id );
$qb_1->getQuery()->execute();
$em -> flush();
现在级联删除正在运行。