php - 用 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,
]);
}
解决方案
推荐阅读
- avplayer - iOS 13+ 应用程序的 AVAudioPlayer AVPlayer AVQueuePlayer MPMusicPlayerController MPRemoteCommandCenter MPNowPlayingInfoCenter 之间的区别
- swift - 发出不调用 sqlite3_bind 的 SQLite INSERT 是否“错误”?
- leaflet - 如何在选项卡和多个 geoJson 属性中使用带有两个地图的 Leaflet.Clusters?
- git - 使用带有凭据的 Jenkinsfile 管道将标签添加到存储库
- javascript - Android Chrome 使用 JavaScript 从前置摄像头切换到后置摄像头
- python - 如何使用 cpython 将结构的 C 结构传输到 python
- jquery - Can I use jQuery to have users add/remove content to a site?
- linux - 为什么我的 crontab 不能正确执行 bash?
- sql - 折叠空单元格上的行以在 SQL 中提供单行结果
- indexing - 使用 LIKE 进行子字符串搜索是否受益于索引?