PHP code example of tuum / pagination

1. Go to this page and download the library: Download tuum/pagination 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/ */

    

tuum / pagination example snippets


use Tuum\Pagination\Inputs;
use Tuum\Pagination\Pagination;

$pager = new Pager();
$pager->withRequest($request); // PSR-7 server request.
$inputs = $pager->getInputs();

$found = $pdo->prepare("SELECT * FROM tbl WHERE type=? and num>? OFFSET ? LIMIT ?")
    ->execute([
        $inputs->get('type'),
        $inputs->get('num'),
        $inputs->getOffset(),
        $inputs->getLimit(),
    ])
    ->fetchAll();

echo $inputs;

$pages = $inputs->getPagination();
$pages->numLinks = 7;
$pagination = new ToBootstrap3($paginate)
echo $pagination;

$inputs->setTotal(
    $pdo->prepare("SELECT COUNT(*) FROM tbl WHERE type=? and num>? ")
        ->execute([
            $inputs->get('type'),
            $inputs->get('num')
        ])
        ->fetchColumn()
);

$pager->pager->useValidator(function(&$v) {
        $v = 'validate=' . $v;
    });

function (&$v) {
	if (!is_string($v) && !is_numeric($v)) {
        $v = '';
    } elseif (strpos($v, "\0") !== false) {
        $v = '';
    } elseif (!mb_check_encoding($v, 'UTF-8')) {
        $v = '';
    }
};