1 | <?php |
||
2 | |||
3 | namespace Willry\QueryBuilder; |
||
4 | |||
5 | class Query extends Base |
||
6 | { |
||
7 | |||
8 | /** |
||
9 | * @param string $columns |
||
10 | * @return $this |
||
11 | */ |
||
12 | public function selectRaw(string $columns = "*", array $params = []): self |
||
13 | { |
||
14 | $this->setBindings($params, 'select'); |
||
15 | $this->columns = array_merge($this->columns, explode(',', $columns)); |
||
16 | return $this; |
||
17 | } |
||
18 | |||
19 | public function select(array $columns = ['*']): self |
||
20 | { |
||
21 | $this->columns = array_merge($this->columns, $columns); |
||
22 | return $this; |
||
23 | } |
||
24 | |||
25 | /** |
||
26 | * @param string $columnOrder |
||
27 | */ |
||
28 | public function order(string $columnOrder): self |
||
29 | { |
||
30 | $this->order = "ORDER BY ?"; |
||
31 | $this->setBindings([$columnOrder], 'order'); |
||
32 | return $this; |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * @param array $group |
||
37 | * @return DB |
||
0 ignored issues
–
show
|
|||
38 | */ |
||
39 | public function groupBy(string $group): self |
||
40 | { |
||
41 | |||
42 | $this->groupBy = "GROUP BY {$group}"; |
||
43 | return $this; |
||
0 ignored issues
–
show
|
|||
44 | } |
||
45 | |||
46 | /** |
||
47 | * @param string $having |
||
48 | * @return DB |
||
49 | */ |
||
50 | public function having(string $having, array $params = []): self |
||
51 | { |
||
52 | $this->having = "HAVING {$having}"; |
||
53 | $this->setBindings($params, 'having'); |
||
54 | return $this; |
||
0 ignored issues
–
show
|
|||
55 | } |
||
56 | |||
57 | /** |
||
58 | * @param int $limit |
||
59 | */ |
||
60 | public function limit(int $limit): static |
||
61 | { |
||
62 | $this->limit = "LIMIT ?"; |
||
63 | $this->setBindings([$limit], 'limit'); |
||
64 | return $this; |
||
65 | } |
||
66 | |||
67 | /** |
||
68 | * @param int $offset |
||
69 | * @return DB |
||
70 | */ |
||
71 | public function offset(int $offset): static |
||
72 | { |
||
73 | $this->offset = "OFFSET ?"; |
||
74 | $this->setBindings([$offset], 'offset'); |
||
75 | return $this; |
||
0 ignored issues
–
show
|
|||
76 | } |
||
77 | |||
78 | public function get(): ?array |
||
79 | { |
||
80 | $this->mountQuery(); |
||
81 | |||
82 | try { |
||
83 | $stmt = $this->db->prepare($this->query); |
||
84 | QueryHelpers::bind($stmt, $this->flatBindings()); |
||
85 | $stmt->execute(); |
||
86 | |||
87 | return $stmt->fetchAll(\PDO::FETCH_CLASS); |
||
88 | } catch (\PDOException $exception) { |
||
89 | $this->handleError($exception); |
||
90 | } |
||
91 | } |
||
92 | |||
93 | public function first(): ?\stdClass |
||
94 | { |
||
95 | $this->mountQuery(); |
||
96 | |||
97 | try { |
||
98 | $stmt = $this->db->prepare($this->query); |
||
99 | QueryHelpers::bind($stmt, $this->flatBindings()); |
||
100 | $stmt->execute(); |
||
101 | |||
102 | if (!$stmt->rowCount()) { |
||
103 | return null; |
||
104 | } |
||
105 | |||
106 | return $stmt->fetchObject(); |
||
107 | } catch (\PDOException $exception) { |
||
108 | $this->handleError($exception); |
||
109 | } |
||
110 | } |
||
111 | |||
112 | public function count(): ?int |
||
113 | { |
||
114 | $this->mountQuery(); |
||
115 | |||
116 | try { |
||
117 | $stmt = $this->db->prepare($this->query); |
||
118 | QueryHelpers::bind($stmt, $this->flatBindings()); |
||
119 | $stmt->execute(); |
||
120 | |||
121 | return $stmt->rowCount(); |
||
122 | } catch (\PDOException $exception) { |
||
123 | $this->handleError($exception); |
||
124 | } |
||
125 | } |
||
126 | } |
||
127 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths