| @@ 21-35 (lines=15) @@ | ||
| 18 | * |
|
| 19 | * @link http://stackoverflow.com/questions/2135418/equivalent-of-limit-and-offset-for-sql-server |
|
| 20 | */ |
|
| 21 | protected function compileLimit(int $limit, int $offset): string |
|
| 22 | { |
|
| 23 | if (empty($limit) && empty($offset)) { |
|
| 24 | return ''; |
|
| 25 | } |
|
| 26 | ||
| 27 | //Modern SQLServer are easier to work with |
|
| 28 | $statement = "OFFSET {$offset} ROWS "; |
|
| 29 | ||
| 30 | if (!empty($limit)) { |
|
| 31 | $statement .= "FETCH NEXT {$limit} ROWS ONLY"; |
|
| 32 | } |
|
| 33 | ||
| 34 | return trim($statement); |
|
| 35 | } |
|
| 36 | } |
|
| @@ 418-434 (lines=17) @@ | ||
| 415 | * |
|
| 416 | * @return string |
|
| 417 | */ |
|
| 418 | protected function compileLimit(int $limit, int $offset): string |
|
| 419 | { |
|
| 420 | if (empty($limit) && empty($offset)) { |
|
| 421 | return ''; |
|
| 422 | } |
|
| 423 | ||
| 424 | $statement = ''; |
|
| 425 | if (!empty($limit)) { |
|
| 426 | $statement = "LIMIT {$limit} "; |
|
| 427 | } |
|
| 428 | ||
| 429 | if (!empty($offset)) { |
|
| 430 | $statement .= "OFFSET {$offset}"; |
|
| 431 | } |
|
| 432 | ||
| 433 | return trim($statement); |
|
| 434 | } |
|
| 435 | ||
| 436 | /** |
|
| 437 | * Compile where statement. |
|