當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Paging::show方法代碼示例

本文整理匯總了PHP中Paging::show方法的典型用法代碼示例。如果您正苦於以下問題:PHP Paging::show方法的具體用法?PHP Paging::show怎麽用?PHP Paging::show使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Paging的用法示例。


在下文中一共展示了Paging::show方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: findPage

 /**
  * 分頁查詢
  * 
  * @access public
  * @param mixed $page
  * @param int $list_num
  * @param int $type
  * @param bool $ajax
  * @param string $ajaxFunction
  * @return source
  */
 public function findPage($page, $list_num = 20, $type = 1, $ajax = false, $ajaxFunction = '')
 {
     $list_num = $list_num > 0 ? (int) $list_num : 20;
     $sql = $this->sql;
     $this->sql['limit'] = '';
     $alias = preg_replace('/.+\\s+as\\s+(\\w+)\\s*/', "\$1.", $this->sql['table']);
     if ($alias == $this->sql['table']) {
         $alias = "";
     }
     if ($this->sql['group'] != '') {
         $this->sql['fields'] = $this->primary_key ? 'count(distinct(' . $alias . $this->primary_key . ')) as total' : 'count(*) as total';
     } else {
         $this->sql['fields'] = $this->primary_key ? 'count(' . $alias . $this->primary_key . ') as total' : 'count(*) as total';
     }
     $this->sql['order'] = "";
     $this->sql['group'] = "";
     $result = $this->query();
     $total = isset($result[0]['total']) ? $result[0]['total'] : 0;
     $total_page = round(($total - 1) / $list_num) + 1;
     if ($page > $total_page) {
         $page = $total_page;
     }
     $option = array("total_nums" => $total, "pagesize" => $list_num, "plus" => 3, "page" => $page, "ajax" => $ajax, "ajaxFunction" => $ajaxFunction);
     $pageing = new Paging($option);
     $data['html'] = $pageing->show(5);
     $this->sql = $sql;
     $page = $page > 0 ? (int) $page : 1;
     $start_id = $list_num * ($page - 1);
     $this->sql['limit'] = "limit {$start_id}, {$list_num}";
     $data['data'] = $this->query();
     $data['page'] = array('total' => $total, 'totalPage' => $total_page, 'pageSize' => $list_num, 'page' => $page);
     return $data;
 }
開發者ID:sammychan1981,項目名稱:quanpin,代碼行數:44,代碼來源:model_class.php


注:本文中的Paging::show方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。