/** * 构造函数 * * @param int $totalRows 总行数 * @param int $listRows 每页显示条数 * @param string $param分页跳转时带的参数 * * @return void */ public function __construct($totalRows, $listRows = 20, $param = '') { $this->totalRows = $totalRows; $this->listRows = $listRows ? intval($listRows) : 10; $this->varPage = Config::get('VAR_PAGE') ? Config::get('VAR_PAGE') : 'p'; $this->param = $param; $this->totalPages = ceil($this->totalRows / $this->listRows); $this->coolPages = ceil($this->totalPages / $this->rollPage); $this->nowPage = Input::getInt($this->varPage, 2); if ($this->nowPage < 1) { $this->nowPage = 1; } elseif (!empty($this->totalRows) && $this->nowPage > $this->totalPages) { $this->nowPage = $this->totalPages; } $this->firstRow = $this->listRows * ($this->nowPage - 1); }
/** * 构造函数 * * @param int $totalRows 总行数 * @param int $numPerPage 每页显示条数 * @param array $param 分页跳转时带的参数 如:['name' => '张三'] */ public function __construct($totalRows, $numPerPage = 20, $param = []) { $this->totalRows = $totalRows; $this->numPerPage = $numPerPage ? intval($numPerPage) : 10; $this->pageShowVarName = Config::get('var_page') ? Config::get('var_page') : 'p'; $this->param = $param; $this->totalPages = ceil($this->totalRows / $this->numPerPage); $this->coolPages = ceil($this->totalPages / $this->barShowPage); $this->nowPage = Input::getInt($this->pageShowVarName, 1); if ($this->nowPage < 1) { $this->nowPage = 1; } elseif (!empty($this->totalRows) && $this->nowPage > $this->totalPages) { $this->nowPage = $this->totalPages; } $this->firstRow = $this->numPerPage * ($this->nowPage - 1); }