本文整理匯總了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);
}