Symfony2: Call to a member function getId() on a non-object even though there is an object?

前端 未结 1 705
迷失自我
迷失自我 2021-01-19 06:13

I keep getting this error:

    /* ... */
    $em = $this->getDoctrine()->getEntityManager();
    $movie = $em->getRepository(\'MyMyBundle:Movie\')-&         


        
相关标签:
1条回答
  • 2021-01-19 06:20

    Nevermind, I found the answer: echo $movie[0]->getId(); (the repository returned an array of objects). Sorry, sometimes you lose sight of the wood for the trees.

    0 讨论(0)
提交回复
热议问题