PHP code example of kejawenlab / ci4pager

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

    

kejawenlab / ci4pager example snippets


// In your controller
use KejawenLab\CodeIgniter\Pagination\Paginator;

$results = $db->query('SELECT * FROM users');
$page = 1;

$paginator = Paginator::createFromResult($results, $page);

echo view('records', ['paginator' => $paginator]);

//In your view
foreach ($paginator->getResults() as $result) {
    //your result here
}

kejawenlab_ci4_pager($paginator, [
    'base_url' => 'http://base_url.com/users',
    'current_text' => 'Current Page',
    'total_text' => 'Total Records',
]);

// In your controller
use KejawenLab\CodeIgniter\Pagination\Paginator;

$queryBuilder = $db->table('users');
$page = 1;

$paginator = Paginator::createFromQueryBuilder($queryBuilder, $page);

echo view('records', ['paginator' => $paginator]);

//In your view
foreach ($paginator->getResults() as $result) {
    //your result here
}

kejawenlab_ci4_pager($paginator, [
    'base_url' => 'http://base_url.com/users',
    'current_text' => 'Current Page',
    'total_text' => 'Total Records',
]);

// In your controller
use KejawenLab\CodeIgniter\Pagination\Paginator;

$results = $db->table('users')->get()->getResultArray();
$page = 1;

$paginator = Paginator::createFromArray($results, $page);

echo view('records', ['paginator' => $paginator]);

//In your view
foreach ($paginator->getResults() as $result) {
    //your result here
}

kejawenlab_ci4_pager($paginator, [
    'base_url' => 'http://base_url.com/users',
    'current_text' => 'Current Page',
    'total_text' => 'Total Records',
]);