diversen/simple-pager

该包已被 废弃 且不再维护。未建议替代包。

围绕 pear-pager 的简单分页包装器

v1.3.29 2017-02-03 18:29 UTC

This package is auto-updated.

Last update: 2021-07-20 10:10:50 UTC


README

分页类是围绕 PEAR::Pager 的简单包装器

它通过知道查询中的 $_GET['from'] 部分来工作,并从这个参数中,类知道将是什么页面集的下一页。您不需要考虑这一点,因为分页类将处理这一切

安装

与所有依赖于 pear 的包一样,您需要将 pear 添加到 repositories 部分中。

{
    "repositories": [
        {
            "type": "pear",
            "url": "https://pear.php.net"
        }

    ],
    "require": {
        "diversen/simple-pager": "^1.3"

    }
}

如果您已将 pear 添加到 repositories,可以通过以下方式安装

composer require diversen/simple-pager

示例

use diversen\pagination;

// Get a count of rows from a database
// A database query to get the number of rows
// You will need your own way of getting your count of rows
$num_rows = q::numRows('mailer_archive')->fetch();
$per_page = 50;   
     
// Initialize the paginate class, with the total number
// of pages and how many per page. 
$p = new pagination($num_rows, $per_page);

// the rows to display
$rows = q::select('mailer_archive')->
            limit($p->from, $per_page)->
            fetch();

// Display the rows 
foreach($rows as $row) {
    print_r($row);
}
            
// Echo the pager data. 
echo $p->getPagerHTML();

CSS

您可以在 css/example.css 中找到 CSS 示例