本文整理汇总了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;
}