2

当我尝试使用此查询时:

$repository = $this->getDoctrine()
                    ->getRepository('AcmeCommentoBundle:Commento');
                    $query = $repository->createQueryBuilder('p')
                            ->select('DISTINCT p.user')
                            ->where('p.annuncio = :annuncio')
                            ->setParameter('annuncio', $annuncio)
                            ->getQuery();

                    $utenti = $query->getResult();

它返回此错误:

[Semantical Error] line 0, col 18 near 
    'user FROM Acme\CommentoBundle\Entity\Commento': 
     Error: Invalid PathExpression. Must be a StateFieldPathExpression. 

这个错误是什么意思?

4

1 回答 1

2

解决了

$query = $repository->createQueryBuilder('p')
                        ->distinct('p.user')
                        ->where('p.annuncio = :annuncio')
                        ->setParameter('annuncio', $annuncio)
                        ->getQuery();
于 2013-01-28T17:33:14.403 回答