public function applyLimitOffset($sql, $limit = -1, $offset = -1)
{
$limit = $limit !== null ? intval($limit) : -1;
$offset = $offset !== null ? intval($offset) : -1;
if ($limit > 0 || $offset > 0) {
$limitStr = ' LIMIT ' . $limit;
$offsetStr = $offset >= 0 ? ' OFFSET ' . $offset : '';
return $sql . $limitStr . $offsetStr;
} else {
return $sql;
}
}