开发者

Doctrine 2.0 entity with relations - delete record

When I delete record from Entity with relations (@onetoone or @onetomany)

All relations records will deleted too

    $em = $this->getEm();
    $post = $em->find('Blog\\WebBundle\\Entity\\Posts', $pid);
    // not found
    if (!$post) {
        throw ExceptionController::notFound('The post does not ex开发者_StackOverflowist.');
    }
    $em->remove($post);
    $em->flush();

    return $this->redirectGenerate('_posts');

For example this code, remove user, that create post too, because between posts and users there is a relations

How to avoid this?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜