msSQL - also handle offset as string

When doing pagination you could get offset not as a int(eg. 10) but string(eg. "10") and it will not paginate at all.

For example DataTables plugin pass offset from params and all params from http request are strings wrapped in numbers.
Adding ctype_digit($offset) will also check the case.
This commit is contained in:
kolorafa 2017-10-05 11:45:33 +02:00 committed by GitHub
parent b3d83afb81
commit 22d2564de9

View file

@ -411,7 +411,7 @@ class Sqlserver extends DboSource {
$rt = ' TOP';
}
$rt .= sprintf(' %u', $limit);
if (is_int($offset) && $offset > 0) {
if ((is_int($offset) || ctype_digit($offset)) && $offset > 0) {
$rt = sprintf(' OFFSET %u ROWS FETCH FIRST %u ROWS ONLY', $offset, $limit);
}
return $rt;