I'm trying to use Query Builder in Symfony2.3 and I keep getting the error:
FatalErrorException: Error: Call to a member function createQueryBuilder()
on a non-object in...line 45
which is the second part of my query,
$query = $tokenobject->createQueryBuilder('t')
->select('t.token','t.user', 't.expirationdate')
->where('t.user = :username','t.token = :token')
->setParameter('username', $Username)
->setParameter('token', $Token)
->orderBy('t.expirationdate', 'ASC')
->setMaxResults(1);
The entire code if it helps:
$confirmationrepository = $this->getDoctrine()
->getRepository('TravelTravelBundle:Confirmation')
->findByuser($Username);
$query = $confirmationrepository ->createQueryBuilder('t')
->select('t.token','t.user', 't.expirationdate')
->where('t.user = :username','t.token = :token')
->setParameter('username', $Username)
->setParameter('token', $Token)
->orderBy('t.expirationdate', 'ASC')
->setMaxResults(1);
$token = $query->getResult();
I know for a fact $confirmationrepository is finding table column'user' properly and that $Username and $Token (being routed into controller) are set and routing properly.
Is there something wrong with my syntax, or is there some other explanation for what is happening?
$confirmationrepository = $this->getDoctrine()
->getRepository('TravelTravelBundle:Confirmation')
->findByuser($Username);
should be
$confirmationrepository = $this->getDoctrine()
->getRepository('TravelTravelBundle:Confirmation');
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