Created
November 7, 2018 10:10
-
-
Save SeunMatt/df9d88822bead128251862bdd31098ab to your computer and use it in GitHub Desktop.
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
SQL SERVER-SIDE PAGINATION | |
========================== | |
```php | |
$realOffset = 0; | |
if(!is_null($limit) && $offset > 0) { | |
$realOffset = $offset * $limit; | |
} | |
if($offset < 0) { | |
$realOffset = 0; | |
} | |
if(!is_null($limit)) | |
$CI->db->limit($limit, $realOffset); | |
``` | |
SERVER-SIDE PAGINATION LOGIC FOR ELASTIC SEARCH | |
=============================================== | |
``` | |
if(page > 1) | |
realOffset = (page * limit) - limit; | |
- limit is the same as size or total number of records per page that I want | |
- page is the page number e.g. 1,2,3,4... | |
- realOffset is the actual value to pass to the search API as the from key | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment