Conditions | 5 |
Paths | 4 |
Total Lines | 29 |
Lines | 0 |
Ratio | 0 % |
Tests | 14 |
CRAP Score | 5.1374 |
Changes | 0 |
1 | <?php |
||
13 | 2 | public function select($fields, string $table, array $params = []) |
|
14 | { |
||
15 | 2 | if (is_array($fields)) { |
|
16 | $fields = implode(', ', $fields); |
||
17 | } |
||
18 | |||
19 | 2 | $query = "SELECT $fields FROM $table"; |
|
20 | 2 | $binds = []; |
|
21 | |||
22 | 2 | if (count($params)) { |
|
23 | 1 | $where = []; |
|
24 | 1 | foreach ($params as $k => $v) { |
|
25 | 1 | $v = (array) $v; |
|
26 | 1 | if (count($v) == 1) { |
|
27 | 1 | $binds[$k] = $v[0]; |
|
28 | 1 | $where[] = $k.' = :'.$k; |
|
29 | } else { |
||
30 | $binds[$k] = $v; |
||
31 | $where[] = $k.' in (:'.$k.')'; |
||
32 | } |
||
33 | } |
||
34 | |||
35 | 1 | $where = implode(' and ', $where); |
|
36 | |||
37 | 1 | $query .= " where $where"; |
|
38 | } |
||
39 | |||
40 | 2 | return $this->get(Client::class)->select($query, $binds); |
|
41 | } |
||
42 | |||
59 |