Stevan Tosic Stevan Tosic - 10 months ago 67
PHP Question

Doctrine findBy() calling method from entity

I need little help to call method from entity.

Here is the code I had try to execute.

$datat = $this->getDoctrine()
->findBy(array('userId' => $userId));

after this, when I call


I get message about exeption "Error: Call to a member function getUser() on a non-object"

When I dump $data I got data from table or if I execute

with ID value.


findBy returns generally an ArrayCollection.

You should use findOneBy instead in order to target only one entity...

So :

$datat = $this->getDoctrine()  
   ->findOneBy(array('userId' => $userId));