public function buildLimit($limit, $offset)
{
$sql = '';
if (is_int($offset) && $offset > 0 || is_string($offset) && ctype_digit($offset) && $offset !== '0') {
$sql = 'LIMIT ' . $offset;
}
if (is_string($limit) && ctype_digit($limit) || is_int($limit) && $limit >= 0) {
$sql = $sql === '' ? "LIMIT {$limit}" : "{$sql},{$limit}";
} elseif ($sql !== '') {
$sql .= ',1000';
// this is the default limit by sphinx
}
return $sql;
}