PHP code example of spacetab-io / paginate
1. Go to this page and download the library: Download spacetab-io/paginate library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
spacetab-io / paginate example snippets
use Spacetab\Paginate\Paginator;
use Spacetab\Paginate\Adapter\SqlAdapter;
use Amp\Postgres;
use function Amp\call;
call(function() {
$connection = new Postgres\ConnectionConfig('127.0.0.1');
$paginator = new Paginator(new SqlAdapter(new Postgres\Pool($connection), 'table_name'));
$paginator->setPage($query['page'] ?? null);
$paginator->setPerPage($query['per_page'] ?? null);
/** @var \Spacetab\Paginate\ResultSet $results */
$results = yield $paginator->doPaginate();
$results->getItems();
$results->getCount();
$results->getPrev();
$results->getNext();
$results->getTotal();
});