我試圖存儲形式進入數據庫的一些領域,使用此代碼:Symfony2的形式 - 實體店到數據庫
$data = $form->getData();
$em=$this->getDoctrine()->getManager();
$em=persist($data->getCompany());
$em->flush();
return $this->redirectToRoute('target_success');}
,但我得到以下錯誤:
Attempted to call function "persist" from namespace "site\formBundle\Controller".
任何幫助將受到歡迎。
persist是一個'Entity Manager'方法,而不是一個PHP函數 – Trix