我不断收到此错误:
/* ... */
$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() 方法。即使其他方法也不起作用is并反对!
对象被转储,如下所示:
..... array(1) { [0]=> object(stdClass)#759 (59) { ["__CLASS__"]=> string( .....
有什么提示吗?
没关系,我找到了答案:echo $movie[0]->getId();
(存储库返回一个对象数组)。抱歉,有时候只见树木不见森林。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)