• phpcms v9后台多表查询分页代码


    用phpcms v9开发网页用到分页的时候,发现没有多表查询的分页,经过查询资料和看网友的帖子,加上自己的实验,实现了多表关联查询结果的分页效果

    文件:model.class.php

    final public function mylistinfo($where = '',$countWhere, $page = 1, $pagesize = 10, $key='', $setpages = 10,$urlrule = '',$array = array()) {
    // $where = to_sqls($where);
    $this->number = $this->count($countWhere);
    $page = max(intval($page), 1);
    $offset = $pagesize*($page-1);
    $this->pages = pages($this->number, $page, $pagesize, $urlrule, $array, $setpages);
    $array = array();
    if ($this->number > 0) {
    //$where.' LIMIT '.$offset.','.$pagesize
    //$result = $this->query($where, "$offset, $pagesize");
    $result = $this->query($where.' LIMIT '.$offset.','.$pagesize);
    return $this->fetch_array();
    } else {
    return array();
    }
    }

    前台调用:

    $page = isset($_GET['page']) && trim($_GET['page']) ? intval($_GET['page']) : 1;
    $sql = "SELECT A.NO,A.AREANAME,concat(A.AREANO,'(',B.BEGINTIME,'-',B.ENDTIME,')') AS AREANO,A.USERID,A.EVENTTIME,A.BOOKDATE,A.AREASTATUS FROM b6_book A,b6_subarea B where A.AREANO=B.AREANO AND A.USERID='".$memberinfo['userid']."' AND BOOKDATE>='".date('Y-m-d')."' ORDER BY BOOKDATE";
    $booklist = $this->book_db->mylistinfo($sql,"userid ='".$memberinfo['userid']."' and bookdate>='".date('Y-m-d')."'",$page);
    $pages = $this->book_db->pages;

  • 相关阅读:
    巴厘岛的雕塑(sculptures)
    BZOJ4361: isn
    BZOJ2131: 免费的馅饼
    BZOJ4240: 有趣的家庭菜园
    BZOJ5484: [Usaco2018 Dec]Sort It Out
    BZOJ 2151: 种树
    HDU 1285 确定比赛名次(拓扑排序+优先队列)
    申请中文域名并跳转到个人网站(多种方法的尝试)
    Java binarysearch方法
    eclipse2019-12设置中文
  • 原文地址:https://www.cnblogs.com/gscheng/p/5193327.html
Copyright © 2020-2023  润新知