zoukankan      html  css  js  c++  java
  • thinkphp 原生分页

     paginate() 是有三个参数:

    • 第一个参数是 $listRows [int],也就是当前的页数
    • 第二个参数是 $simple [boolean], 是否简洁模式或者总记录数
    • 第三个参数是 $config [array],配置参数
    /**
         * 分页查询
         * @param int|array $listRows 每页数量 数组表示配置参数
         * @param int|bool  $simple   是否简洁模式或者总记录数
         * @param array     $config   配置参数
         *                            page:当前页,
         *                            path:url路径,
         *                            query:url额外参数,
         *                            fragment:url锚点,
         *                            var_page:分页变量,
         *                            list_rows:每页数量
         *                            type:分页类名
         * @return 	hinkPaginator
         * @throws DbException
         */
        public function paginate($listRows = null, $simple = false, $config = []){}

    带参数分页

    $status = $_GET['status']; // 为了演示 直接用$_GET
    // 构造查询条件
    $where [''status] = $status;
    // 构造额外的条件
    $pageParam=[
        'status' => $status,
        'type' => $type
    ];
    // 进行分页查询
    $list = $Post->where($where)->paginate(10,false,array('query'=>$pageParam));
    // 获取page
    $page = $postListInfo->render();
    $this->assign('postListInfo',$postListInfo);
    $this->assign('page', $page);

    参考:https://www.kancloud.cn/manual/thinkphp5/154294

  • 相关阅读:
    recyclerView DiffUtil使用
    RecyclerView实现侧滑删除、置顶、滑动
    Android RecyclerView
    视频框架 Vitamio使用
    react native初始化项目
    react native环境搭建
    javascript Promise
    javascript 基础
    [IOS学习笔记]KVO
    [IOS学习笔记] UINavigationController Demo
  • 原文地址:https://www.cnblogs.com/blogpro/p/11388611.html
Copyright © 2011-2022 走看看