3

Symfony2.3 で Query Builder を使用しようとしていますが、エラーが発生し続けます: FatalErrorException: Error: Call to a member function createQueryBuilder() on a non-object in...line 45

これはクエリの 2 番目の部分です。

$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(コントローラーにルーティングされている)が設定され、適切にルーティングされていることを知っています。

私の構文に何か問題がありますか、それとも何が起こっているのかについて他の説明がありますか?

4

2 に答える 2

4
$confirmationrepository = $this->getDoctrine()
        ->getRepository('TravelTravelBundle:Confirmation')
        ->findByuser($Username);

する必要があります

$confirmationrepository = $this->getDoctrine()
        ->getRepository('TravelTravelBundle:Confirmation');
于 2013-09-03T09:12:02.100 に答える
0

->findByuser($ユーザー名); エントリの配列をフェッチします。したがって、 $confirmationrepository は配列であり、期待したリポジトリ クラスではありません。findByuser 行を省略してください。

于 2013-09-03T09:11:50.213 に答える