Trying to run a query with symfony and I get this error:
[Syntax Error] line 0, col 83: Error: Expected end of string, got 'username'
This code throws that error:
$query = $em->createQuery(
'SELECT username
FROM BLOGBlogBundle:user
WHERE username= :usrname'
)->setParameter('usrname', $usr);
$products = $query->getResult();
What am I doing wrong?
Seems to work when you add in the alias
$query = $em->createQuery('
SELECT u.username
FROM BLOGBlogBundle:user u
WHERE u.username = :usrname')
->setParameter('usrname', $usr);
$products = $query->getResult();
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