2017 © Pedro Peláez
 

package paginate

Simple pagination class

image

hadi/paginate

Simple pagination class

  • Sunday, September 10, 2017
  • by im4aLL
  • Repository
  • 1 Watchers
  • 0 Stars
  • 18 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 13 % Grown

The README.md

Installation

composer require hadi/paginate

Usage

require_once __DIR__ . '/../vendor/autoload.php';

$config = [
    'host' => 'localhost',
    'name' => 'abworkout',
    'username' => 'root',
    'password' => '',
];

$db = new \Hadi\Database();                                             // https://github.com/im4aLL/pdo-mysql-driver
$db->connect($config);

$total = $db->query("SELECT id FROM orders")->get();

$paginate = new \Hadi\Paginate([
    'per_page' => 1,
    'page_param' => 'page',
    'page_url' => 'http://localhost/paginate/test/',
    'total_record' => count($total),
]);

$orders = $db->query("SELECT * FROM orders ".$paginate->limit())->get();

echo $paginate->limit().' <br><br>';

foreach($orders as $order) {
    echo $order->id.' - ';
    echo $order->order_number;
    echo '<br>';
}

$db->disconnect();

More usage

<br><br>
Total records: = $paginate->totalRecord() ?>



Page = $paginate->currentPage() ?> of = $paginate->totalPage() ?>
<a href="<?= $paginate->previousPageUrl() ?>">Previous page</a> <a href="<?= $paginate->nextPageUrl() ?>">Next page</a>
<a href="<?= $paginate->firstPageUrl() ?>">First page</a> <a href="<?= $paginate->lastPageUrl() ?>">Last page</a>
<?php foreach($paginate->pages() as $page) { if($page['number']) { echo ' <a href="'.$page['url'].'">'.$page['number'].'</a> '; } else { echo ' ... '; } }

The Versions

10/09 2017

dev-master

9999999-dev

Simple pagination class

  Sources   Download

MIT

The Requires

 

by Habib Hadi

10/09 2017

1.0.0

1.0.0.0

Simple pagination class

  Sources   Download

MIT

The Requires

 

by Habib Hadi