Reputation: 19
I have a simple controller as following:
public function fetchDataAction($username){
$user_email = $this -> getDoctrine()
-> getRepository('AdminBundle:Users')
-> findBy( array('username' => $username ), array('id' => 2));
return $this -> render('AdminBundle:Admin:fetchData.html.twig', array('datas' => $user_email));
}
But in running the code I face the error:
Invalid order by orientation specified for AdminBundle\Entity\Users#userId
Passing one array to findBy()
method, the code run errorlessly, But When I pass multiple arrays, It fails!
Where is the problem?
Upvotes: 0
Views: 847
Reputation: 54831
Problem is that second parameter to findBy
is sort order. Passing array('id' => 2)
as a sort order causes your error (if you've read it's text).
So the solution is to pass both filter criterias in one array:
-> findBy( array('username' => $username, 'id' => 2) );
Upvotes: 2