Answer the question
In order to leave comments, you need to log in
Why won't remove() from the database work?
Hello,
please help me figure it out. I have one or more "pages" on a "book".
When I delete a book, it disappears from the database, but its pages remain.
The framework doesn't swear - but what I'm doing is definitely wrong.
Please point out the error. Thank you!
/**
* @Route("/site/delete/{idSite}", name="delete")
*/
public function delete(Request $request, $idSite){
$liste_books=$this->getDoctrine()->getRepository(Book::class)->findOneBy(['idSite'=>$idSite]);
$liste_pages=$this->getDoctrine()->getRepository(Page::class)->findBy(['idSite'=>$idSite]);
$em = $this->getDoctrine()->getManager();
$em->remove($liste_books, $liste_pages); // так можно делать?
$em->flush();
return $this->redirectToRoute('site');
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question