使用DB :: select进行laravel分页

时间:2016-10-22 11:37:49

标签: laravel pagination

如何在分页结果中获取查询结果的总计数。

ex:$result=DB::select("select * from table");
$pagination = new Paginator($result, $resultsPerPage, $currentPage);

上面给出了结果页面和当前页面但是如何计算总数。

第四个参数需要作为数组类型我试过但它不起作用。 我需要这样的结果。

 {
        "total": 32,
        "per_page": 4,
        "current_page": 1,
        "last_page": 8,
        "next_page_url":  "http://192.168.0.117/projects/videoSharingApp/VSA/public/me/videos?page=2",
        "prev_page_url": null,
        "from": 1,
        "to": 4,
    }

0 个答案:

没有答案
相关问题