thinkphp几个表的数据合并,并用数组分页

控制器:

//金币扣除
public function jbkc(){
        $map['UG_dataType']= 'xtkc';
        $list1 = M ( 'userget' )->where ( $map )->select ();
        $list2 = M ( 'userget2' )->where ( $map )->select ();
        $list3 = M ( 'userget3' )->where ( $map )->select ();
        $list0=array_merge($list1,$list2,$list3);
        $count=count($list0);
        $p = getpage($count,20);
        $list=array_slice($list0,$p->firstRow,$p->listRows);
        $this->assign ( 'list', $list );
        $this->assign ( 'page', $p->show());
        $this->display('index/jbkc');
    }

 公共函数:

function getpage($count, $pagesize = 10) {
	$p = new Think\Page($count, $pagesize);
	$p->setConfig('header', '<li class="rows">共<b>%TOTAL_ROW%</b>条记录 第<b>%NOW_PAGE%</b>页/共<b>%TOTAL_PAGE%</b>页</li>');
	$p->setConfig('prev', '上一页');
	$p->setConfig('next', '下一页');
	$p->setConfig('last', '末页');
	$p->setConfig('first', '首页');
	$p->setConfig('theme', '%FIRST%%UP_PAGE%%LINK_PAGE%%DOWN_PAGE%%END%%HEADER%');
	$p->lastSuffix = false;//最后一页不显示为总页数
	return $p;
}

 

posted @ 2016-06-07 10:15  绿尘枫  阅读(4340)  评论(0编辑  收藏  举报