首页 > 解决方案 > 用 Where 子句替换有原因

问题描述

请我在 symfony 的项目中遇到一些麻烦

我如何替换上面这段代码中的有子句 wuíth where 子句导致有子句在 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();
}

谢谢

当我使用这样的有子句 symfony 响应时

无法计算使用 HAVING 子句的查询。使用输出步行器进行分页

而这个功能

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,


    ]);


}

标签: phpsqlsymfonywhere-clausehaving-clause

解决方案


推荐阅读