我正在尝试进行分页,但是有一个错误:
$dql = "SELECT cast(ip as CHAR) as ip FROM histories";
$query = $em->createQuery($dql)->setFirstResult($offset)->setMaxResults($limit);
$paginator = new Paginator($query);
$maxpage = ceil($paginator->count() / $limit);
错误
[语法错误]第0行,col 7:错误:预期识别variable | scalarexpression |汇总表达|函数销售| partialObjectexpression |"(" subselect")" |casexpression,得到'*'
$ maxpage = ceil($ paginator-> count()/$ limit);//错误行
请尝试:
$maxpage = ceil(count($paginator) / $limit);
阅读doc