【发布时间】:2012-07-13 08:18:12
【问题描述】:
我不断收到此错误:
/* ... */
$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( .....
有什么提示吗?
【问题讨论】:
-
您使用的是自定义实体存储库吗?如果是,请发布
findMovieByName方法。 -
谢谢吉尔登。是的,它是一个自定义实体存储库。但我找到了答案(现在花了我大约一个小时)。 :) 谢谢!