your learning Symfony neighbor here,
I am calling a method from my controller through Ajax on a select change. I manage to get the data I send to the controller, but I'm struggling as I try to make a Select with the data I get, for some reason, no matter the existing column I decide to return, I get a "specifiedColumn is not defined" and I can't figure out why.
Here's my method :
public function getPricesAction(Request $request)
{
$first = $request->request->get('first');
$final = $request->request->get('final');
$em = $this->getDoctrine()->getManager();
//not too sure about stacking 2 setParameter here, guess there's a better way. But even if I just use one parameter, I still get the same error 'id is not defined'.
$getPrice = $em->createQuery('SELECT id FROM CarsBundle:Travel t WHERE t.first = :tst and t.final = :tfi')->setParameter('tre', $first)->setParameter('tra', $final);
$result = $getPrice->getResult();
return new JsonResponse($result);
}
I am using Symfony 3.3
thanks for the help !
$getPrice = $em->createQuery('SELECT id FROM CarsBundle:Travel t WHERE t.first = :tst and t.final = :tfi')->setParameter('tre', $first)->setParameter('tra', $final);
Should be:
$getPrice = $em->createQuery('SELECT id FROM CarsBundle:Travel t WHERE t.first = :tst and t.final = :tfi')->setParameter('tst', $first)->setParameter('tfi', $final);
You got the wrong parameter name