PHPackages                             tharangakothalawala/resultsetpaginator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. tharangakothalawala/resultsetpaginator

ActiveLibrary[Database &amp; ORM](/categories/database)

tharangakothalawala/resultsetpaginator
======================================

Simple pagination module where it accepts a database connection to provide pagination support. Also supports plain pagination.

v1.2.0(7y ago)01.3kPHPPHP &gt;=5.3

Since Nov 21Pushed 7y ago1 watchersCompare

[ Source](https://github.com/tharangakothalawala/resultsetpaginator)[ Packagist](https://packagist.org/packages/tharangakothalawala/resultsetpaginator)[ RSS](/packages/tharangakothalawala-resultsetpaginator/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (2)Versions (4)Used By (0)

ResultSet Paginator
===================

[](#resultset-paginator)

This is a simple set of classes that provides you pagination data for a given query. This executes a query using a given database connection (PDO, mysqli). Also supports plain pagination.

[![Build Status](https://camo.githubusercontent.com/3a07dcb85ecaf35970e795c7638c61dda81832bb8e73283315796e41a0c568a9/68747470733a2f2f7472617669732d63692e6f72672f74686172616e67616b6f7468616c6177616c612f726573756c74736574706167696e61746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/tharangakothalawala/resultsetpaginator)[![Total Downloads](https://camo.githubusercontent.com/b0e6e3195a528a19210e3381be1c84f4600900bd74b4023354adf030150fb452/68747470733a2f2f706f7365722e707567782e6f72672f74686172616e67616b6f7468616c6177616c612f726573756c74736574706167696e61746f722f642f746f74616c2e737667)](https://packagist.org/packages/tharangakothalawala/resultsetpaginator)[![Latest Stable Version](https://camo.githubusercontent.com/8d3a28116594d086e895f1d163dffb859458dde3a94e3f5067e793563689c8a8/68747470733a2f2f706f7365722e707567782e6f72672f74686172616e67616b6f7468616c6177616c612f726573756c74736574706167696e61746f722f762f737461626c652e737667)](https://packagist.org/packages/tharangakothalawala/resultsetpaginator)[![License](https://camo.githubusercontent.com/f45d904953153ca304a2328243d2733e095eee13a631a1f390709885d41dd692/68747470733a2f2f706f7365722e707567782e6f72672f6c61726176656c2f6672616d65776f726b2f6c6963656e73652e737667)](https://packagist.org/packages/tharangakothalawala/resultsetpaginator)

Usage Examples
--------------

[](#usage-examples)

### Pagination with known result total count

[](#pagination-with-known-result-total-count)

```
use TSK\ResultSetPaginator\Paginator\PaginationProvider;

$page = empty($_GET['page']) ? 3 : $_GET['page'];
$limit = empty($_GET['limit']) ? 10 : $_GET['limit'];
$totalResultCount = $laravelModel->count(); // "SELECT COUNT(*) FROM table" for example

$paginationProvider = new PaginationProvider($page, $limit, $totalResultCount);
$paginationProvider->setVisiblePaginationRange(1);

$modelItems => $laravelModel
    ->offset($paginationProvider->offset())
    ->limit($limit)
    ->get();

$pagination = '';
foreach($paginationProvider->pages() as $page) {
    if ($page->isCurrentPage()) {
        $pagination .= " {$page->getDisplayValue()} ";
        continue;
    }

    $pagination .= " {$page->getDisplayValue()} ";
}

echo $pagination;
```

##### The above example will produce the below output:

[](#the-above-example-will-produce-the-below-output)

&lt;&lt; &lt; 2 3 4 &gt; &gt;&gt;

### Example usage with a PDO connection (ex: Laravel)

[](#example-usage-with-a-pdo-connection-ex-laravel)

```
use TSK\ResultSetPaginator\QueryExecerFactory;

$page = empty($_GET['page']) ? 2 : $_GET['page'];
$limit = empty($_GET['limit']) ? 10 : $_GET['limit'];

$queryExecerFactory = new QueryExecerFactory(DB::connection()->getPdo(), $page, $limit);
$queryExecer = $queryExecerFactory->getQueryExecer();

/** @var \PDOStatement $stmt */
$stmt = $queryExecer->query($sql);
$records = $stmt->fetchAll();

$pagination = '';
foreach($queryExecer->paginationProvider()->pages() as $page) {
    if ($page->isCurrentPage()) {
        $pagination .= " {$page->getDisplayValue()} ";
        continue;
    }

    $pagination .= " {$page->getDisplayValue()} ";
}

echo $pagination;
```

##### The above example will produce the below output:

[](#the-above-example-will-produce-the-below-output-1)

&lt;&lt; &lt; 1 2 3 4 5 &gt; &gt;&gt;

### Example usage with a mysqli connection

[](#example-usage-with-a-mysqli-connection)

```
use TSK\ResultSetPaginator\QueryExecerFactory;

$page = empty($_GET['page']) ? 2 : $_GET['page'];
$limit = empty($_GET['limit']) ? 10 : $_GET['limit'];

$dbConn = new mysqli('localhost', 'tharanga', 'qwerty', 'test');

$queryExecerFactory = new QueryExecerFactory($dbConn, $page, $limit);
$queryExecer = $queryExecerFactory->getQueryExecer();

/** @var \mysqli_result $resultset */
$resultset = $queryExecer->query($sql);
//while($row = $resultset->fetch_assoc()) {
//    $records[] = $row;
//}

$pagination = '';
foreach($queryExecer->paginationProvider()->pages() as $page) {
    if ($page->isCurrentPage()) {
        $pagination .= " {$page->getDisplayValue()} ";
        continue;
    }

    $pagination .= " {$page->getDisplayValue()} ";
}

echo $pagination;
```

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~565 days

Total

3

Last Release

2742d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/618527?v=4)[Tharanga Gamaethige](/maintainers/tharanga)[@tharanga](https://github.com/tharanga)

---

Top Contributors

[![tharangakothalawala](https://avatars.githubusercontent.com/u/4851255?v=4)](https://github.com/tharangakothalawala "tharangakothalawala (12 commits)")

---

Tags

mysqlipaginatepaginationpagination-librarypagination-supportpaginatorpdo

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tharangakothalawala-resultsetpaginator/health.svg)

```
[![Health](https://phpackages.com/badges/tharangakothalawala-resultsetpaginator/health.svg)](https://phpackages.com/packages/tharangakothalawala-resultsetpaginator)
```

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k116.5M113](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[jfelder/oracledb

Oracle DB driver for Laravel

11518.4k](/packages/jfelder-oracledb)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
