Recommend this page to a friend! |
Classes of Allan Kibet | Simple PDO Pagination class | README.md | Download |
|
DownloadSimple PDO Pagination PackageThis is a simple PHP package that lets you paginate your select queries making it easier to navigate a list of records with simple navigation links. Composer Installation
<?php use Pagination\Pager; // Create your PDO connection object $pdo = new \PDO("mysql:host=localhost;port=3306;dbname=testdb", 'root', 'r00t'); // Initiate your pager $p = new Pager($pdo, "SELECT * FROM users"); // Set you page URL $p->setPageUrl("http://localhost/users"); // Set your per page limit $p->setPerPage(10); $dataRecords = $p->paginate()->data; foreach($dataRecords as $data) {
} if(isset($p->paginate()->firstLink)) {
} if(isset($p->paginate()->backLink)) {
} echo "[{$p->paginate()->currentPage}]"; if(isset($p->paginate()->nextLink)) {
} if(isset($p->paginate()->lastLink)) {
}
header('Content-Type: application/json'); echo $p->paginateJSON();
|