ThinkPHP5 : 分页paginate()

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即可,框架会自动返回该页数据

你可能感兴趣的:(thinkphp,thinkphp)