Skip to content

Instantly share code, notes, and snippets.

@anjan011
Created August 17, 2016 16:49
Show Gist options
  • Save anjan011/152d2e9c4fc833a0aefc2599e4f80f0c to your computer and use it in GitHub Desktop.
Save anjan011/152d2e9c4fc833a0aefc2599e4f80f0c to your computer and use it in GitHub Desktop.
mysql sample limit clause generation
<?php
$pageNo = isset($limitParams['_ticketPage']) ? (int)$limitParams['_ticketPage'] : 1;
if($pageNo < 1) {
$pageNo = 1;
}
$recordsNo = isset($limitParams['_ticketRecords']) ? (int)$limitParams['_ticketRecords'] : 20;
if($recordsNo < 1) {
$recordsNo = 1;
}
$offset = ($pageNo - 1) * $recordsNo;
$limitClause = " limit {$offset},{$recordsNo}";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment