Download .zip |
Info | Documentation | View files (11) | Download .zip | Reputation | Support forum (1) | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2019-09-08 (9 days ago) | Not enough user ratings | Total: 76 This week: 76 | All time: 9,421 This week: 3 |
Version | License | PHP version | Categories | |||
simple-pdo-pager 1.0 | BSD License | 7 | PHP 5, Databases |
Description | Author | |||||||||||||
This class can get results and links for queries split in pages. |
|
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.
### 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 |
File | Role | Description | ||
---|---|---|---|---|
.idea (6 files) | ||||
src (1 directory) | ||||
composer.json | Data | Auxiliary data | ||
composer.lock | Data | Auxiliary data | ||
phpunit.xml | Data | Auxiliary data | ||
README.md | Doc. | Read me |
Files | / | .idea |
File | Role | Description |
---|---|---|
misc.xml | Data | Auxiliary data |
modules.xml | Data | Auxiliary data |
php.xml | Data | Auxiliary data |
simple-pdo-pager.iml | Data | Auxiliary data |
vcs.xml | Data | Auxiliary data |
workspace.xml | Data | Auxiliary data |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
User Comments (1) | |||||
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.