数据分页如何使用?

留恋风(2581047041@qq.com)

返回首页

引入框架自带的分页类,demo如下:

namespace app\home\c;
use frphp\lib\Controller;
use frphp\extend\Page;//使用系统分页扩展空间命名

class DemoController extends Controller
{
	public function index(){
		$page = new Page('test');//实例化分页类
		$sql = '1=1';//查询条件
		$data = $page->where($sql)->orderby('id desc')->limit($this->frparam('limit',0,10))->page($this->frparam('page',0,1))->go();
		$this->lists = $data;//列表数据
		$this->pages = $page->pageList();//组合分页
		$this->sum = $page->sum;//总数据
		$this->listpage = $page->listpage;//分页数组-自定义分页可用
		$this->prevpage = $page->prevpage;//上一页
		$this->nextpage = $page->nextpage;//下一页
		$this->allpage = $page->allpage;//总页数
		$this->limit = $page->limit;//分页条数
		$this->display('test/page');
	}
}

案例

返回首页