<?php
class pagesModel extends Model{
        public function store_page($pagesize=25,$map,$order){
			$data = M('store'); // 实例化User对象
			import('ORG.Util.Page');// 导入分页类
			$map .= " and is_delete= '0' ";
			$count      = $data->where($map)->count();// 查询满足要求的总记录数
			$Page       = new Page($count,$pagesize);// 实例化分页类 传入总记录数和每页显示的记录数
			$show       = $Page->show();// 分页显示输出
			// 进行分页数据查询 注意limit方法的参数要使用Page类的属性
			// $list = $data->where($map)->order($order)->limit($Page->firstRow.','.$Page->listRows)->select();
			$list = $data->query("select a.*,b.username from ". C('DB_PREFIX') ."store as a left join ". C('DB_PREFIX') ."users as b on a.uid=b.id where ". $map ." ". $order ." limit ". $Page->firstRow . "," . $Page->listRows);
			$return['list'] = $list;
			$return['page'] = $show;
			return $return;
		}
		/*pagesize = 每页显示数量
		map = 查询条件
		order = 排序方式
		url = 增加的url参数
		*/
        public function content_page($pagesize=25,$map,$order,$model='',$url=''){
			$data = M('content_content'); // 实例化User对象
			import('ORG.Util.Page');// 导入分页类
			// $map .= " and is_delete= '0' ";
			$q = str_replace('a.','',$map);
			$count      = $data->where($q)->count();// 查询满足要求的总记录数
			$Page       = new Page($count,$pagesize,'',$model,$url);// 实例化分页类 传入总记录数和每页显示的记录数
			$Page->setConfig('first','1...');
			$Page->setConfig('prev','上一页');
			$Page->setConfig('next','下一页');
			$Page->setConfig('last','尾页');
			$Page->setConfig('theme','%upPage% %first% %linkPage% %downPage% %end%');
			$show       = $Page->show();// 分页显示输出
			// 进行分页数据查询 注意limit方法的参数要使用Page类的属性
			// $list = $data->where($map)->order($order)->limit($Page->firstRow.','.$Page->listRows)->select();
			$list = $data->query("select a.*,b.value,c.authpic from ". C('DB_PREFIX') ."content_content as a left join ". C('DB_PREFIX') ."content_yesno as b on a.id=b.cid left join ". C('DB_PREFIX') ."users as c on a.authorid=c.id where ". $map ." ". $order ." limit ". $Page->firstRow . "," . $Page->listRows);
			// echo $data->getLastSql();
			foreach($list as $k=>$v){
				$list_data[$k] = $v;
				$list_data[$k]['yi'] = unserialize($v['value']);
			}
			$return['list'] = $list_data;
			$return['page'] = $show;
			return $return;
		}
		/*pagesize = 每页显示数量
		map = 查询条件
		order = 排序方式
		url = 增加的url参数
		*/
        public function comment_page($pagesize=25,$map,$order,$model='',$url=''){
			$data = M('content_comment'); // 实例化User对象
			import('ORG.Util.Page');// 导入分页类
			// $map .= " and is_delete= '0' ";
			$q = str_replace('a.','',$map);
			$count      = $data->where($q)->count();// 查询满足要求的总记录数
			$Page       = new Page($count,$pagesize,'',$model,$url);// 实例化分页类 传入总记录数和每页显示的记录数
			$Page->setConfig('first','1...');
			$Page->setConfig('prev','上一页');
			$Page->setConfig('next','下一页');
			$Page->setConfig('last','尾页');
			$Page->setConfig('theme','%upPage% %first% %linkPage% %downPage% %end%');
			$show       = $Page->show();// 分页显示输出
			// 进行分页数据查询 注意limit方法的参数要使用Page类的属性
			// $list = $data->where($map)->order($order)->limit($Page->firstRow.','.$Page->listRows)->select();
			$list = $data->query("select a.*,c.authpic,c.username from ". C('DB_PREFIX') ."content_comment as a left join ". C('DB_PREFIX') ."content_content as b on a.cid=b.id left join ". C('DB_PREFIX') ."users as c on a.uid=c.id where ". $map ." ". $order ." limit ". $Page->firstRow . "," . $Page->listRows);
			// echo $data->getLastSql();
			$return['list'] = $list;
			$return['page'] = $show;
			return $return;
		}
		public function member_page($pagesize=25,$map,$order,$model='',$url=''){
			$data = M('users'); // 实例化User对象
			import('ORG.Util.Page');// 导入分页类
			// $map .= " and is_delete= '0' ";
			$count      = $data->where($q)->count();// 查询满足要求的总记录数
			$Page       = new Page($count,$pagesize,'',$model,$url);// 实例化分页类 传入总记录数和每页显示的记录数
			$Page->setConfig('first','1...');
			$Page->setConfig('prev','上一页');
			$Page->setConfig('next','下一页');
			$Page->setConfig('last','尾页');
			$Page->setConfig('theme','%upPage% %first% %linkPage% %downPage% %end%');
			$show       = $Page->show();// 分页显示输出
			// 进行分页数据查询 注意limit方法的参数要使用Page类的属性
			// $list = $data->where($map)->order($order)->limit($Page->firstRow.','.$Page->listRows)->select();
			$list = $data->query("select * from fm_users where ". $map ." ". $order ." limit ". $Page->firstRow . "," . $Page->listRows);
			//echo $data->getLastSql();
			// print_r($list);
			$return['list'] = $list;
			$return['page'] = $show;
			return $return;
		}
	}