4

我不断收到此错误:

    /* ... */
    $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( .....

有什么提示吗?

4

1 回答 1

11

没关系,我找到了答案:(echo $movie[0]->getId();存储库返回了一个对象数组)。抱歉,有时你只见树木不见森林。

于 2012-07-13T08:36:53.910 回答