1

到目前为止,我有以下查询:

   $shopQuery = $qb->select('DISTINCT u')
                    ->from("BlahUserBundle:User", 'u')
                    ->innerJoin('u.followers', 'followers')
                    ->andWhere('followers.id != :userId')
                    ->setParameter('userId', $user->getId())
                    ->orWhere('') //or where those user who doesn't have a follower yet
                    //->setMaxResults(5)
                    ;

我正在尝试找到一种方法来查询所有没有追随者且追随者不是我自己的用户(在这种情况下,我的自己是$user->getId())。我该怎么做?

4

1 回答 1

1

尝试这个

$shopQuery = $qb->from("BlahUserBundle:User", 'u')
            ->leftJoin(
                'u.followers',
                'followers',
                'on',
                'followers.id != :userId'
            )
            ->where('followers.id IS NULL')
            ->setParameter('userId', $user->getId());
$shopQuery->getQuery()->getResults();
于 2013-11-15T09:32:34.587 回答