我正在尝试在 Symfony2.3 中使用查询生成器,但我不断收到错误消息:
FatalErrorException: Error: Call to a member function createQueryBuilder()
on a non-object in...line 45
这是我查询的第二部分,
$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);
如果有帮助的话,整个代码:
$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();
我知道一个事实是正确地$confirmationrepository
找到表列,并且(被路由到控制器)设置和路由正确。'user'
$Username
$Token
我的语法有问题,还是对正在发生的事情有其他解释?