$Product = D('Product');
$p = I('get.p');
//获取页面的作品信息
$list = $Product->getIndexProductByTimestamp($p);
$this->assign('list',$list);
// 查询满足要求的总记录数
$count = $Product->getProductCountByTimestamp();
// 实例化分页类 传入总记录数和每页显示的记录数
$Page = new \Think\Page($count,16);
// 分页显示输出
$show = $Page->show();
// 赋值分页输出
$this->assign('page',$show);
$this->display('Index/index');ProductModel.class.php里面的函数function getIndexProductByTimestamp($p){
// 进行分页数据查询 注意page方法的参数的前面部分是当前的页数使用 首页获取的$_GET[p]获取 默认是0,既是首页
$list = $this->order('product_createtime desc')->page($p.',16')->select();
return $list;
}
function getProductCountByTimestamp(){
return $this->order('product_createtime desc')->count();
} 最佳答案