Replace Having Cause with Where Clause

  having-clause, php, sql, symfony, where-clause

Please i have some trouble in my project in symfony

How can i replace having clause wuĆ­th where clause in this code above cause having clause dont work white paginator in symfony

 public function getAllClients($all = true, $user = null)
    $qb = $this->_em->createQueryBuilder();


    $qb->select('u, count( as nbr')
        ->from($this->_entityName, 'u')
        ->join(Client::class, 'c', Join::WITH, 'c.user =')
        ->join(LicenceShop::class, 'ls', Join::WITH, 'ls.client =')
        ->having('nbr > 1');

    $qb->andWhere('u.roles LIKE :roles');
    $qb->setParameter('roles', '%"ROLE_CLIENT"%');

    return $qb->getQuery();

Thanks you

When i use having clause symfony response like that

Cannot count query that uses a HAVING clause. Use the output walkers for pagination

And this the function

enter code public function show($id = null, UserRepository $userRepository, Request $request, PaginatorInterface $paginator)

        $user = $userRepository->find($id);
        $user = $this->getUser();

    $client = $user->getClientInfo();
    $myClients = $userRepository->getAllClients(false, $user);

    $myClients = $paginator->paginate(
        $request->query->getInt('page_c', 100)

    $referal = null;
    $licences = null;
    if ($client) {
        $referal = $client->getReferal();
        $licences = $client->getLicences();

    //$licences = $module->getLicences();
    return $this->render('resellers/show.html.twig', [
        'controller_name' => 'ResellersController',
        'user' => $user,
        'client' => $client,
        'referal' => $referal,
        'licences' => $licences,
        'my_clients' => $myClients,



Source: Symfony Questions