2015-10-23 68 views
0

當我嘗試檢查某個表是否已存在某個id時,出現此錯誤,但出現錯誤「調用成員函數getIdProcesoAcumulado()非對象」上在非對象上調用成員函數getIdProcesoAcumulado()

這是控制器:

public function AcumularAction($id){ 
    $idAcumulado = $this->getRequest()->get('acumulado'); 
    $em = $this->getDoctrine()->getEntityManager(); 
    $proceso =$em->getRepository('ProcesoBundle:ProcesoDisciplinario')->find($id); 
    $acumulado = $em->getRepository('ProcesoBundle:ProcesoDisciplinario')->find($idAcumulado); 
    $existe = $em->getRepository('ProcesoBundle:ProcesoAcumulado')->find($idAcumulado); 
    $acum = new ProcesoAcumulado(); 
    $existe->getIdProcesoAcumulado(); 
    if(! $acumulado){ 
     return new JsonResponse(array('exito' => false)); 
    }else{ 
     $acum->setIdProcesoAcumulado($acumulado); 
     $acum->setIdProceso($proceso); 
     //$acum->setNroInternoAcum(); 
     $em->persist($acum); 
     $em->flush(); 
     return new JsonResponse(array('exito' => true)); 
    } 
} 

,這是GET:

/** 
* Get idProcesoAcumulado 
* 
* @return integer 
*/ 
public function getIdProcesoAcumulado() 
{ 
    return $this->idProcesoAcumulado; 
} 
+4

嘗試'轉儲($ existe);'這可能是'NULL'。如果是這樣,這是因爲'$ em-> getRepository('ProcesoBundle:ProcesoAcumulado') - > find($ idAcumulado);'不返回所需的實體。 –

回答

1

如果該對象$ existe爲空,我不能得到的價值 - > getIdProcesoAcumulado()。

嘗試:

if($existe){ 
    $existe->getIdProcesoAcumulado(); 
} 
相關問題