These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * KumbiaPHP web & app Framework. |
||
4 | * |
||
5 | * LICENSE |
||
6 | * |
||
7 | * This source file is subject to the new BSD license that is bundled |
||
8 | * with this package in the file LICENSE.txt. |
||
9 | * It is also available through the world-wide-web at this URL: |
||
10 | * http://wiki.kumbiaphp.com/Licencia |
||
11 | * If you did not receive a copy of the license and are unable to |
||
12 | * obtain it through the world-wide-web, please send an email |
||
13 | * to [email protected] so we can send you a copy immediately. |
||
14 | * |
||
15 | * @category Kumbia |
||
16 | * |
||
17 | * @copyright 2005 - 2016 Kumbia Team (http://www.kumbiaphp.com) |
||
18 | * @license http://wiki.kumbiaphp.com/Licencia New BSD License |
||
19 | */ |
||
20 | namespace Kumbia\ActiveRecord\Query; |
||
21 | |||
22 | /** |
||
23 | * Adiciona limit y offset a la consulta sql en pgsql. |
||
24 | * |
||
25 | * @param string $sql consulta select |
||
26 | * @param string $limit valor limit |
||
27 | * @param string $offset valor offset |
||
28 | * |
||
29 | * @return string |
||
30 | */ |
||
31 | View Code Duplication | function pgsql_limit($sql, $limit = null, $offset = null) |
|
0 ignored issues
–
show
|
|||
32 | { |
||
33 | if ($limit !== null) { |
||
34 | $limit = (int) $limit; |
||
35 | $sql .= " LIMIT $limit"; |
||
36 | } |
||
37 | |||
38 | if ($offset !== null) { |
||
39 | $offset = (int) $offset; |
||
40 | $sql .= " OFFSET $offset"; |
||
41 | } |
||
42 | |||
43 | return $sql; |
||
44 | } |
||
45 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.