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