Skip to content

Commit

Permalink
Update limit() in SQLServer to handle large page numbers as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed May 3, 2013
1 parent d403631 commit 3d682ba
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Cake/Model/Datasource/Database/Sqlserver.php
Expand Up @@ -384,9 +384,9 @@ public function limit($limit, $offset = null) {
if (!strpos(strtolower($limit), 'top') || strpos(strtolower($limit), 'top') === 0) {
$rt = ' TOP';
}
$rt .= ' ' . $limit;
$rt .= sprintf(' %u', $limit);
if (is_int($offset) && $offset > 0) {
$rt = ' OFFSET ' . intval($offset) . ' ROWS FETCH FIRST ' . intval($limit) . ' ROWS ONLY';
$rt = sprintf(' OFFSET %u ROWS FETCH FIRST %u ROWS ONLY', $offset, $limit);
}
return $rt;
}
Expand Down

0 comments on commit 3d682ba

Please sign in to comment.