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?
精彩评论