Last active
January 10, 2024 08:36
-
-
Save totoprayogo1916/0352933ec74b9c89fc1d6073116c7bfb to your computer and use it in GitHub Desktop.
Codeigniter 4 Pagination (manual setting $limit & $offset)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$page = (int) $this->request->getGet('page'); // | |
$limit = config('Pager')->perPage; // see Config/Pager.php | |
if (!isset($page) || $page === 0 || $page === 1) { | |
$page = 1; | |
$offset = 0; | |
} else { | |
$offset = ($page - 1) * $limit; | |
$page = $page; | |
} | |
// $mymodel->myfunction($limit, $offset)->get()->getResult(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment