ThinkPHP5 : 分页paginate()

发布时间:2022-09-13 16:00

paginate(每页数量,是否简洁分页,分页参数)

使用方式

$fileList = Db::name('test')
    ->field('id, name, abstract, path, ctime')
    ->paginate($limit);

返回数据如下:

        "total": 2,
        "per_page": 15,
        "current_page": 1,
        "last_page": 1,
        "data": [
            {
                "id": 2,
                "cate_id": 33,
                "name": "163827538361a61937d084f_test2.doc",
                "abstract": "zhaiyao",
                "path": "http://localhost:8100/static/uploads/files/2021/11/30/163827538361a61937d084f_test2.doc",
                "ctime": 1638275350,
                "cate": ""
            },
            {
                "id": 3,
                "cate_id": 33,
                "name": "163849307461a96b9252358_test.doc",
                "abstract": "zhaiyao ",
                "path": "http://localhost:8100/static/uploads/files/2021/12/03/163849307461a96b9252358_test.doc",
                "ctime": 1638493078,
                "cate": ""
            }
        ]

需要获取指定的页数时,传入参数page即可,框架会自动返回该页数据

ItVuer - 免责声明 - 关于我们 - 联系我们

本网站信息来源于互联网,如有侵权请联系:561261067@qq.com

桂ICP备16001015号