From 22d2564de95d7d58e7e3d091f000aa96b86bf34f Mon Sep 17 00:00:00 2001 From: kolorafa Date: Thu, 5 Oct 2017 11:45:33 +0200 Subject: [PATCH] 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. --- lib/Cake/Model/Datasource/Database/Sqlserver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Model/Datasource/Database/Sqlserver.php b/lib/Cake/Model/Datasource/Database/Sqlserver.php index 03e9f9091..2e9c78fd7 100644 --- a/lib/Cake/Model/Datasource/Database/Sqlserver.php +++ b/lib/Cake/Model/Datasource/Database/Sqlserver.php @@ -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;