| Total Complexity | 9 |
| Total Lines | 19 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 3 | class SelectBuilder { |
||
| 4 | public function select($table, $criteria, $args, $options = []) { |
||
| 5 | $where = $criteria ? ' WHERE ' . $criteria : ''; |
||
| 6 | $limit = (isset($options['limit'])) ? ' LIMIT ' . $options['limit'] : ''; |
||
| 7 | |||
| 8 | if (isset($options['offset'])) { |
||
| 9 | $offset = ' OFFSET ' . $options['offset']; |
||
| 10 | if (!$limit) $limit = ' LIMIT 1000'; |
||
| 11 | } |
||
| 12 | else $offset = ''; |
||
| 13 | |||
| 14 | $order = isset($options['order']) ? ' ORDER BY ' . $options['order'] : ''; |
||
| 15 | return new Query('SELECT * FROM ' . $table . ' ' . $where . $order . $limit . $offset, $args); |
||
| 16 | } |
||
| 17 | |||
| 18 | public function aggregate($table, $function, $field, $where, $args, $group) { |
||
| 22 | } |
||
| 23 | } |
||
| 24 |