• cmf5分页相关


    //分页配置在app/config.php

    'paginate' => [
       'type' => 'cmfpaginatorBootstrap',
       'var_page' => 'page',
       'list_rows' => 15,
    ],

    //分页调用 think/db/Query.php 

    /**
         * 分页查询
         * @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 = [])
        {
            if (is_int($simple)) {
                $total  = $simple;
                $simple = false;
            }
            if (is_array($listRows)) {
                $config   = array_merge(Config::get('paginate'), $listRows);
                $listRows = $config['list_rows'];
            } else {
                $config   = array_merge(Config::get('paginate'), $config);
                $listRows = $listRows ?: $config['list_rows'];
            }
    
            /** @var Paginator $class */
            $class = false !== strpos($config['type'], '\') ? $config['type'] : '\think\paginator\driver\' . ucwords($config['type']);
            $page  = isset($config['page']) ? (int) $config['page'] : call_user_func([
                $class,
                'getCurrentPage',
            ], $config['var_page']);
    
            $page = $page < 1 ? 1 : $page;
    
            $config['path'] = isset($config['path']) ? $config['path'] : call_user_func([$class, 'getCurrentPath']);
    
            if (!isset($total) && !$simple) {
                $options = $this->getOptions();
    
                unset($this->options['order'], $this->options['limit'], $this->options['page'], $this->options['field']);
    
                $bind    = $this->bind;
                $total   = $this->count();
                $results = $this->options($options)->bind($bind)->page($page, $listRows)->select();
            } elseif ($simple) {
                $results = $this->limit(($page - 1) * $listRows, $listRows + 1)->select();
                $total   = null;
            } else {
                $results = $this->page($page, $listRows)->select();
            }
            return $class::make($results, $listRows, $page, $total, $simple, $config);
        }
    View Code

     $class = false !== strpos($config['type'], '\') ? $config['type'] : '\think\paginator\driver\' . ucwords($config['type']);  

    通过配置的路径加载分页类

    $userQuery = Db::name("mall_order");
    $where=$where?$where:['user_id' => $userId];
    $order=$order?$order:'id desc';
    $orderlist = $userQuery->where($where)->order($order)->paginate(10);
    $data['page'] = $orderlist->render(); //分页
    $data['lists'] = $orderlist->items();

  • 相关阅读:
    代码格式化[转]
    ASP.NET错误大杂烩
    Web考勤管理系统 .net 2005 开发
    Ftp 类
    c#中Split等分割字符串的几种方法
    强大的firebug 使用 介绍
    一页面多个文本框回车提交不同事件问题解决
    Ajax电子书下载 发现的好东东贴上了
    编程技术书籍[转]
    推荐下权威的《IT十年经典书系列》1打
  • 原文地址:https://www.cnblogs.com/djiz/p/8295982.html
Copyright © 2020-2023  润新知