本文整理汇总了PHP中think\Page类的典型用法代码示例。如果您正苦于以下问题:PHP Page类的具体用法?PHP Page怎么用?PHP Page使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Page类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPageResult
public function getPageResult($wheres = array())
{
/*
* 分页
* 1.分页工具条
* >>分页类Page(总条数count,每页记录数);
* >>总条数count where(array('status',array('gt',-1)))->$model->count();
* >>每页记录数 自定义也可以配置文件设置
* 2.分页数据查询 排序
* >>limit(firstRow,listRow)
*/
//分页工具条
//$totalRows=where()->count();
$wheres['status'] = array('gt', -1);
$totalRows = $this->where($wheres)->count();
$pageSize = 2;
$page = new Page($totalRows, $pageSize);
//更换主题
if ($page->totalRows > $page->listRows) {
$page->setConfig('theme', '%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% %HEADER%');
}
//当起始行数大于总行数
/**
* $page->firstRow 起始行数
* $page->totalRows 总行数
* $page->listRows 每页记录数
*/
if ($page->firstRow >= $totalRows && $page->firstRow > 0) {
$page->firstRow = $totalRows - $pageSize;
}
$pageHtml = $page->show();
//分页数据查询
$row = $this->where($wheres)->order('sort desc')->limit($page->firstRow, $page->listRows)->select();
return array('rows' => $row, 'pageHtml' => $pageHtml);
}
示例2: loadRecharges
/**
* 加载机构流水数据。
* @param string $agencyId 机构ID
* @param string $typeId 交易类型ID
* @param string $flowId 资金流向ID
* @param string $channelId 资金渠道ID
* @param string $statusId 状态ID
* @return void
*/
public function loadRecharges($agencyId, $typeId, $flowId, $channelId, $statusId)
{
if (APP_DEBUG) {
trace("加载机构流水数据[agency=>{$agencyId}][type=>{$typeId}][flow=>{$flowId}][channel=>{$channelId}][status=>{$statusId}]...");
}
$_where = array();
//机构ID
if (isset($agencyId) && !empty($agencyId)) {
$_where['agency_id'] = $agencyId;
}
//交易类型ID
if (isset($typeId) && !empty($typeId)) {
$_where['type_id'] = $typeId;
}
//资金流向ID
if (isset($flowId) && !empty($flowId)) {
$_where['flow_id'] = $flowId;
}
//资金渠道ID
if (isset($channelId) && !empty($channelId)) {
$_where['channel_id'] = $channelId;
}
//状态ID
if (isset($statusId) && !empty($statusId)) {
$_where['status_id'] = $statusId;
}
//查询统计
$_totalRows = $this->table('hk_agency_fund_water_view')->where($_where)->count();
//查询数据
$_page = new Page($_totalRows);
$_data = $this->table('hk_agency_fund_water_view')->where($_where)->limit($_page->firstRow . ',' . $_page->listRows)->order('last_time desc')->select();
//初始化数据模型
return array('data' => $_data, 'page' => $_page->show());
}
示例3: getPageResult
public function getPageResult($wheres = array())
{
//过滤掉不显示出来的数据
$wheres['obj.status'] = array('gt', -1);
//准备分页工具条数据
$pageHtml = '';
$pageSize = 3;
$this->alias('obj');
$totalRows = $this->where($wheres)->count();
//显示的总条数
$page = new Page($totalRows, $pageSize);
$pageHtml = $page->show();
//生成分页的html
//当输入的页码过大无数据时,停留在最后一页
if ($page->firstRow >= $totalRows) {
$page->firstRow = $totalRows - $page->listRows;
}
if ($totalRows < 3) {
$page->firstRow = 0;
}
//为当前模型对应的表指定一个别名
$this->alias('obj');
//使用表连接查询
$this->_setModel();
//准备分页列表数据
$rows = $this->where($wheres)->limit($page->firstRow, $page->listRows)->select();
//进一步处理数据
$this->_handleRows($rows);
//返回数据
return array('rows' => $rows, 'pageHtml' => $pageHtml);
}
示例4: getListWithPage
public function getListWithPage($wheres = array())
{
//定义pageRasult为数组,rows为每页数据显示,pageTool是分页工具条
//定义每页显示的数据的限制 status>-1
$this->alias('obj');
//设置表的别名,方便连表查询
$wheres['obj.status'] = array('gt', -1);
//分页工具条
$totalRows = $this->where($wheres)->count();
$listRows = 5;
//生成page对象,并设置分页工具条的显示状态
$pageModel = new Page($totalRows, $listRows);
//设置分页工具条的外观
$pageModel->setConfig('theme', '%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% %HEADER%');
$pageTool = $pageModel->show();
//如果总行数小于或等于每页起始行数,则将起始行数设置为总行数减去每页显示的行数
if ($totalRows <= $pageModel->firstRow) {
$pageModel->firstRow = $totalRows - $listRows;
if ($pageModel->firstRow <= 0) {
$pageModel->firstRow = 0;
}
}
$this->alias('obj');
//设置表的别名,方便连表查询
//设置连表查询的钩子方法
$this->_setModel();
//每页显示条数
$rows = $this->where($wheres)->limit($pageModel->firstRow, $pageModel->listRows)->select();
//设置钩子方法来修改rows中的数据
$this->_setRows($rows);
//将结果返回
return array('rows' => $rows, 'pageTool' => $pageTool);
}
示例5: search
public function search()
{
$keyword = I("post.keyword");
if ($keyword) {
$_SESSION['keyword'] = $keyword;
} else {
if ($_SESSION['keyword']) {
$keyword = $_SESSION['keyword'];
}
}
if ($keyword) {
$total = M('Ask')->where(array("sfz" => $keyword))->count();
$Page = new \Think\Page($total, 10);
$this->assign('page', $Page->show());
$result = M("Ask")->where(array("sfz" => $keyword))->limit($Page->firstRow . ',' . $Page->listRows)->order("id DESC")->select();
foreach ($result as $key => $value) {
$member = M("Member")->where(array("uid" => $value["uid"]))->find();
$result[$key]["nickname"] = $member["nickname"];
}
if (!empty($result)) {
$this->assign("ask", $result);
$this->display("my");
} else {
$this->error("无查询结果!", U('Index/respond_to_society'));
}
} else {
$this->error("请输入您的证件号码!", U('Index/respond_to_society'));
}
}
示例6: index
public function index()
{
$id = intval($_GET['id']);
$name = trim($_GET['n']);
$map['title'] = array('LIKE', '%' . str_rp($name) . '%');
$map['uid'] = $id;
$map['status'] = 1;
if (intval($_GET['cid'])) {
$map['cate_id'] = intval($_GET['cid']);
}
if (trim($_GET['type']) == 'new') {
$title['name'] = '最新开班';
$order = 'addtime DESC,sort DESC';
} else {
$title['name'] = '课程列表';
$order = 'sort DESC,read_count DESC';
}
$totalRows = $this->mod->where($map)->count();
$page = new Page($totalRows, 10);
$list = $this->mod->limit($page->firstRow . ',' . $page->listRows)->where($map)->order($order)->select();
$this->list = $list;
$this->assign('page_show', $page->show());
$this->member_seo_set($id, '课程列表');
$this->display();
}
示例7: goods_list
public function goods_list()
{
$perpage = 10;
$page = intval(I("get." . (C('VAR_PAGE') ? C('VAR_PAGE') : 'p'))) ? intval(I('get.' . (C('VAR_PAGE') ? C('VAR_PAGE') : 'p'))) : 1;
$limit = ($page - 1) * $perpage . "," . $perpage;
$cate1 = D("GoodsCategory")->cate1_list();
$this->assign('cate1', $cate1);
if ($_GET) {
$cate1_id = I('get.cate1_id', 0);
$cate2_id = I('get.cate2_id', 0);
$cate3_id = I('get.cate3_id', 0);
$key_word = I('get.key_word', '');
if ($cate1_id > 0) {
$where['cate1_id'] = $cate1_id;
// 分类信息
$where2['cht_category2.cate1_id'] = $cate1_id;
$cate2 = D("GoodsCategory")->cate2_list($where2);
} else {
$where2['cht_category2.cate1_id'] = $cate1[0]['id'];
$cate2 = D("GoodsCategory")->cate2_list($where2);
}
if ($cate2_id > 0) {
$where['cate2_id'] = $cate2_id;
$where3['cht_category3.cate2_id'] = $cate2_id;
$cate3 = D("GoodsCategory")->cate3_list($where3);
} else {
$where3['cht_category3.cate2_id'] = $cate2[0]['id'];
$cate3 = D("GoodsCategory")->cate3_list($where3);
}
if ($cate3_id > 0) {
$where['cate3_id'] = $cate3_id;
}
if ($key_word != '') {
$where['goods_name'] = array('like', "%" . $key_word . "%");
}
$where['store_id'] = UID;
$where['is_show'] = 1;
$goods = $this->_Model->goods_lists($where, $limit);
$total = $this->_Model->goods_count($where);
} else {
// 分类信息
$where2['cht_category2.cate1_id'] = $cate1[0]['id'];
$cate2 = D("GoodsCategory")->cate2_list($where2);
$where3['cht_category3.cate2_id'] = $cate2[0]['id'];
$cate3 = D("GoodsCategory")->cate3_list($where3);
// 获取全部商品
$where = array('store_id' => UID, 'is_show' => 1);
$goods = $this->_Model->goods_lists($where, $limit);
$total = $this->_Model->goods_count($where);
}
$pageobj = new Page($total, $perpage);
$pageobj->setConfig('prev', '上一页');
$pageobj->setConfig('next', '下一页');
$pageshow = $pageobj->show();
$this->assign('cate2', $cate2);
$this->assign('cate3', $cate3);
$this->assign("pageshow", $pageshow);
$this->assign("goods", $goods);
$this->display();
}
示例8: index
public function index()
{
$ac_id = I('cate', 0, 'int');
$pid = M('ArticleClass')->where(array('ac_id' => $ac_id))->getField('ac_parent_id');
if ($pid) {
$this->ac_list = M('ArticleClass')->where(array('ac_parent_id' => $pid))->order('ac_sort desc')->select();
} else {
$this->ac_list = M('ArticleClass')->where(array('ac_parent_id' => $ac_id))->order('ac_sort desc')->select();
}
$ac_list = M('ArticleClass')->order('ac_sort desc')->select();
$ac_list = getChildsId($ac_list, $ac_id, 'ac_id', 'ac_parent_id');
if (is_array($ac_list)) {
$ac_list_str = $ac_id . ',';
foreach ($ac_list as $key => $val) {
$ac_list_str .= $val . ',';
}
$ac_list_str = substr($ac_list_str, 0, -1);
}
$where['ac_id'] = array('IN', $ac_list_str);
$where['article_show'] = 1;
$count = $this->model->where($where)->count();
$page = new Page($count, 10);
$list = $this->model->where($where)->limit($page->firstRow . ',' . $page->listRows)->order('article_sort desc,article_time desc')->select();
$this->list = $list;
$this->page = $page->show();
$this->display();
}
示例9: orderlist
/**
* 用户中心的订单列表
*/
public function orderlist()
{
$session = session('user');
$user_id = 2;
// $session['user_id'];
$data['2cy_order.user_id'] = $user_id;
if (empty($user_id)) {
$this->assign('message', '请登录后再操作');
$this->display('Public/error');
exit;
}
$paytype = I('get.paytype');
if ($paytype != null) {
if ($paytype >= 0) {
$data['2cy_order.order_type'] = $paytype;
}
}
$orderModel = D('Order');
$count = $orderModel->where($data)->count();
$pageshowcount = 5;
$Page = new Page($count, $pageshowcount);
$show = $Page->pageshow();
$orderList = $orderModel->field("2cy_order.user_id,2cy_order.order_type,2cy_order.auther,2cy_order.work_title,2cy_order.pay_money,2cy_order.money,2cy_order.order_id,2cy_order.order_number,2cy_order.create_date,works_comic.main_image_url,works_comic.tags_content")->join('left join works_comic on 2cy_order.work_id = works_comic.id')->order('create_date desc')->limit($Page->firstRow . ',' . $Page->listRows)->where($data)->select();
$paytype = C('paystatus');
$this->assign('orderList', $orderList);
$this->assign('paytype', $paytype);
$this->assign('order_type', $data['2cy_order.order_type']);
$this->assign('show', $show);
$this->display('orderlist');
}
示例10: getPageResult
/**
* 得到分页信息
* @return array
*/
public function getPageResult($where = array())
{
$where['obj.status'] = array('gt', -1);
//得到分页信息
$this->alias('obj');
//设置表别名 查询后失效
$count = $this->where($where)->count();
$size = 10;
$pageTool = new Page($count, $size);
$pageHtml = $pageTool->show();
//得到表信息
$first = $pageTool->firstRow;
if ($first >= $count && $count != 0) {
//超界则总是在最后一页,并且记录不能为0
$first = $count - $size;
}
$this->alias('obj');
//设置表别名
$this->_setModel();
//链表查询--钩子
$rows = $this->where($where)->limit($first, $pageTool->listRows)->select();
//返回结果
$this->_handleRows($rows);
//处理rows数据--钩子
return array('rows' => $rows, 'pageHtml' => $pageHtml);
}
示例11: getHot
public function getHot($hour = 1, $num = 10, $page = 1)
{
$map['create_time'] = array('gt', time() - $hour * 60 * 60);
$map['status'] = 1;
$weiboModel = D('Weibo');
$all_topic = $this->where(array('status' => 1), array(array('read_count' => array('neq', 0))))->select();
foreach ($all_topic as $key => &$v) {
$map['content'] = array('like', "%#{$v['name']}#%");
$v['weibos'] = $weiboModel->where($map)->count();
if ($v['weibos'] == 0) {
unset($all_topic[$key]);
}
$v['user'] = query_user(array('space_link'), $v['uadmin']);
}
unset($v);
$all_topic = $this->arraySortByKey($all_topic, 'weibos', false);
$i = 0;
foreach ($all_topic as &$v) {
$v['top_num'] = ++$i;
}
unset($v);
$pager = new Page(count($all_topic), $num);
// dump($all_topic);exit;
$list['data'] = array_slice($all_topic, ($page - 1) * $num, $num);
$list['html'] = $pager->show();
return $list;
}
示例12: index
public function index()
{
$perpage = 8;
$page = intval(I("get." . (C('VAR_PAGE') ? C('VAR_PAGE') : 'p'))) ? intval(I('get.' . (C('VAR_PAGE') ? C('VAR_PAGE') : 'p'))) : 1;
$limit = ($page - 1) * $perpage . "," . $perpage;
$where = array('user_id' => UID);
if ($_GET) {
$key_word = I('get.key_word', '');
if ($key_word != '') {
$where['title'] = array('like', "%" . $key_word . "%");
}
$requirements = $this->_Model->requirement_lists($where, $limit);
$total = $this->_Model->requirement_count($where);
} else {
// 获取当前买家需求
$requirements = $this->_Model->requirement_lists($where, $limit);
$total = $this->_Model->requirement_count($where);
}
$pageobj = new Page($total, $perpage);
$pageobj->setConfig('prev', '上一页');
$pageobj->setConfig('next', '下一页');
$pageshow = $pageobj->show();
$this->assign("pageshow", $pageshow);
$this->assign("requirements", $requirements);
$this->display();
}
示例13: index
public function index()
{
$where = "int_id = c.id";
$everypage = "10";
//$res = $out->field("id,outtime,outprice,outamount")->relation(true)->order("outtime desc")->select();
$tbName = D("RevenueView");
// 实例化Data数据对象
$count = $tbName->where($where)->count();
// 查询满足要求的总记录数
$Page = new Page($count, $everypage);
// 实例化分页类 传入总记录数和每页显示的记录数(25)
$show = $Page->show();
// 分页显示输出// 进行分页数据查询 注意limit方法的参数要使用Page类的属性
$list = $tbName->where($where)->order("outtime desc")->limit($Page->firstRow . ',' . $Page->listRows)->select();
//print_r($list);
//var_dump($list);
// echo "SQL:" . $tbName->getLastSql();
$this->assign('list', $list);
// 赋值数据集
$this->assign('page', $show);
// 赋值分页输出
$outsum = $tbName->where($where)->sum("outsum");
$this->assign("outsum", $outsum);
$insum = $tbName->sum("insum");
$this->assign("insum", $insum);
$total = $outsum - $insum;
$this->assign("total", $total);
$this->display();
}
示例14: getPageResult
/**
* 得到分页列表中的数据
* $pageResult = >array(
* 'rows'=>二维数组. 分页列表数据
* 'pageHtml'=>分页工具条的html.
* )
*/
public function getPageResult($wheres = array())
{
//有默认的条件, 在调用该方法是不需要传入.
//因为总条数和分页列表都需要查询出状态>-1的数据
$wheres['obj.status'] = array('gt', -1);
//>>1.准备分页工具条html
$pageHtml = '';
$pageSize = 5;
//每页多少条
$this->alias('obj');
$totalRows = $this->where($wheres)->count();
//总条数
$page = new Page($totalRows, $pageSize);
$pageHtml = $page->show();
//生成分页的html
//>>2.准备分页列表数据
//$page->firstRow 起始条数 (页码-1)*每页数
if ($page->firstRow > $totalRows) {
//起始条数大于总条数, 显示最后一页数据.
$page->firstRow = $totalRows - $page->listRows;
//起始条数= 总条数-每页多少条
}
$this->alias('obj');
$this->_setModel();
$rows = $this->where($wheres)->limit($page->firstRow, $page->listRows)->select();
$this->_handleRows($rows);
return array('rows' => $rows, 'pageHtml' => $pageHtml);
}
示例15: getPage
public function getPage($wheres = array())
{
//设置默认值则在调用时可以不用传入参数都可以
//查询条件, 分页的数据和总条数数据都是需要查询出状态大于1的记录
$wheres["obj.status"] = array("gt", -1);
//准备分页工具条
$pageHtml = "";
$pageSize = 5;
//每页多少条
$this->alias('obj');
$count = $this->where($wheres)->count();
//总条数
$page = new Page($count, $pageSize);
$pageHtml = $page->show();
//生成分页的html
//分页数据
//如果起始条数大于总的条数就直接显示最后一页的数据
if ($page->firstRow > $count) {
//起始条数= 总条数-每页多少条
$page->firstRow = $count - $page->listRows;
}
//为表取个别名
$this->alias('obj');
$this->_setModel();
//调用钩子方法
//得到分页后的每页的数据...
$row = $this->where($wheres)->limit($page->firstRow, $page->listRows)->select();
//返回分页数据
return array("rows" => $row, "pageHtml" => $pageHtml);
}