数据库数据是这样的:
想通过having语句把counts > 0的取出来;用到分页,所以having后面连缀分页函数paginate
counts > 0
having
paginate
但是这样报错了:
如果我having后面连缀的是get()函数则没问题,
get()
是可以查到counts > 0的数据的
这是怎么回事呢?
是having后面连缀分页函数paginate存在的bug还是?怎么解决好?
paginate源码
public function paginate($perPage = 15, $columns = ['*'], $pageName = 'page', $page = null) { $page = $page ?: Paginator::resolveCurrentPage($pageName); $total = $this->getCountForPagination($columns); $results = $total ? $this->forPage($page, $perPage)->get($columns) : collect(); return new LengthAwarePaginator($results, $total, $perPage, $page, [ 'path' => Paginator::resolveCurrentPath(), 'pageName' => $pageName, ]); }
paginate默认取表里的字段,表里是木有counts的可换成skip($offset)->take($limit)
counts
skip($offset)->take($limit)
paginate源码
paginate默认取表里的字段,表里是木有
counts
的可换成
skip($offset)->take($limit)