I am new at php symfony framework. i have listed all the passenger detail in the page and also their have a search option, i want to list the details of the person whom i search
if ($request->getMethod() == "POST" && (empty($_POST['name']) == false)) {
$nam = $request->get('name');
$payments = array();
$i = 0;
$entityManager = $this->getDoctrine()->getManager();
$bookingReportQuery =
$entityManager->createQuery("SELECT u.name,u.phone,u.doj
FROM DMBDiamondBundle:Ticketing u
WHERE u.id= (SELECT max(k.id)
FROM DMBDiamondBundle:Ticketing k
WHERE k.name= '$nam')
AND u.name LIKE '$nam%' ")
->setParameter("nam", $nam)
->getResult();
i have an error showing "Invalid parameter number: number of bound variables does not match number of tokens "
I don’t know Symfony at all, so I’m not sure what signifies a parameter. However if it’s anything like PDO bound parameters, you can’t just specify the same parameter name twice in the query if you want to use it twice with the same value, as you seem to be doing with $nam above. You have to use two separate parameter names and, if you need to, give them the same values. The error message pretty much tells you that it’s found a different number of places where you used a parameter, to the number of values you supplied.
I wondered about that, but wondered if that might be a feature of Symfony, perhaps an abstraction layer. So you’re saying it should be just like normal PDO?
Symfony doesn’t change the fundamental inner workings of the php programming language. Also that isn’t Symfony being used there its Doctrine. Doctrine is a well known ORM that is used in Symfony and many other projects.