| Recommend this page to a friend! |
| Info | Documentation | Reputation | Support forum | Blog | Links |
| Ratings | Unique User Downloads | Download Rankings | ||||
| Not enough user ratings | Total: 166 | All time: 8,899 This week: 50 | ||||
| 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();
| File | Role | Description | ||
|---|---|---|---|---|
| Data | Auxiliary data | |||
| Data | Auxiliary data | |||
| Data | Auxiliary data | |||
| Doc. | Read me | |||
| / | .idea |
| File | Role | Description |
|---|---|---|
| |
Data | Auxiliary data |
| |
Data | Auxiliary data |
| |
Data | Auxiliary data |
| |
Data | Auxiliary data |
| |
Data | Auxiliary data |
| |
Data | Auxiliary data |
| The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
| 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.