Replace Having Cause with 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(ls.id) as nbr')
        ->from($this->_entityName, 'u')
        ->join(Client::class, 'c', Join::WITH, 'c.user = u.id')
        ->join(LicenceShop::class, 'ls', Join::WITH, 'ls.client = c.id')
        ->groupBy('u.id')
        ->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)
{




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

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

    $myClients = $paginator->paginate(
        $myClients,
        $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

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *