码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2016-02-16 19:03:42      阅读:200      评论:0      收藏:0      [点我收藏+]

标签:

用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;

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

标签:

原文地址:http://www.cnblogs.com/gscheng/p/5193327.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!