phpcms v9后台多表查询分页代码
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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;
以上是关于phpcms v9后台多表查询分页代码的主要内容,如果未能解决你的问题,请参考以下文章