Skip to content

Instantly share code, notes, and snippets.

@totoprayogo1916
Last active January 10, 2024 08:36
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save totoprayogo1916/0352933ec74b9c89fc1d6073116c7bfb to your computer and use it in GitHub Desktop.
Save totoprayogo1916/0352933ec74b9c89fc1d6073116c7bfb to your computer and use it in GitHub Desktop.
Codeigniter 4 Pagination (manual setting $limit & $offset)
$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