我一直收到这个错误:
/* ... */
$em = $this->getDoctrine()->getEntityManager();
$movie = $em->getRepository('MyMyBundle:Movie')->findMovieByName('moviename'); // Repository Class
\Doctrine\Common\Util\Debug::dump($movie); // dumps the object just fine! The Repository found it
echo $movie->getId(); // brings me the error nevertheless
致命错误:在...线上的非对象上调用成员函数getId()...
我的实体中有getId()方法。即使 是 和对象,其他方法也不起作用!
对象被转储为:
..... array(1) { [0]=> object(stdClass)#759 (59) { ["__CLASS__"]=> string( .....
任何提示?
答案 0 :(得分:11)
没关系,我找到了答案:echo $movie[0]->getId();
(存储库返回了一个对象数组)。对不起,有时你会看不见树木。