PHP Classes
elePHPant
Icontem

Simple PDO Pagination class: Get results and links for queries split in pages

Recommend this page to a friend!
  Info   View files Documentation   View files View files (11)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2019-09-08 (1 month ago) RSS 2.0 feedNot enough user ratingsTotal: 96 This week: 1All time: 9,279 This week: 327Up
Version License PHP version Categories
simple-pdo-pager 1.0BSD License7PHP 5, Databases
Description Author

This class can get results and links for queries split in pages.

It can connect to a given database using PDO and execute a given SQL query.

The class can retrieve result record values for the given query limiting the range of result records to a given page that contains a limited number of records per page.

It can also return the URLs of pages to navigate to other pages of results given a base URL for the current page that displays the paginated listing.

Name: Allan Kibet <contact>
Classes: 2 packages by
Country: Kenya Kenya
Age: ???
All time rank: 29526 in Kenya Kenya
Week rank: 297 Up3 in Kenya Kenya Up

 

Details

Simple PDO Pagination Package

This 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


### Usage

<?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) {

echo $data->id.' '.$data->first_name.' '.$data->last_name.'<br />';

}

if(isset($p->paginate()->firstLink)) {

echo "<a href='{$p->paginate()->firstLink}'> << </a> | ";

}

if(isset($p->paginate()->backLink)) {

echo "<a href='{$p->paginate()->backLink}'> < </a>";

}

echo "[{$p->paginate()->currentPage}]";

if(isset($p->paginate()->nextLink)) {

echo "<a href='{$p->paginate()->nextLink}'> > </a> | ";

}

if(isset($p->paginate()->lastLink)) {

echo "<a href='{$p->paginate()->lastLink}'> >> </a>";

}


for JSON

header('Content-Type: application/json'); echo $p->paginateJSON();

  Files folder image Files  
File Role Description
Files folder image.idea (6 files)
Files folder imagesrc (1 directory)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Read me

  Files folder image Files  /  .idea  
File Role Description
  Accessible without login Plain text file misc.xml Data Auxiliary data
  Accessible without login Plain text file modules.xml Data Auxiliary data
  Accessible without login Plain text file php.xml Data Auxiliary data
  Accessible without login Plain text file simple-pdo-pager.iml Data Auxiliary data
  Accessible without login Plain text file vcs.xml Data Auxiliary data
  Accessible without login Plain text file workspace.xml Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
Files folder imagePagination (1 file)

  Files folder image Files  /  src  /  Pagination  
File Role Description
  Plain text file Pager.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:96
This week:1
All time:9,279
This week:327Up
User Comments (1)