I keep getting this error:
/* ... */
$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
Fatal error: Call to a member function getId() on a non-object in ... on line ...
I have the getId() method in my Entity. Other methods also don't work even though it is and object!
The object gets dumped like:
..... array(1) { [0]=> object(stdClass)#759 (59) { ["__CLASS__"]=> string( .....
Any hints?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With