1 | <?php |
||
2 | namespace NirjharLo\Cgss\Models; |
||
3 | |||
4 | use wpdb; |
||
0 ignored issues
–
show
|
|||
5 | |||
6 | /** |
||
7 | * Simple model for cgss_insight table. |
||
8 | */ |
||
9 | class Insight |
||
10 | { |
||
11 | /** @var wpdb */ |
||
12 | protected $db; |
||
13 | |||
14 | /** @var string */ |
||
15 | protected $table; |
||
16 | |||
17 | public function __construct(?wpdb $db = null) |
||
18 | { |
||
19 | global $wpdb; |
||
20 | $this->db = $db ?: $wpdb; |
||
21 | $this->table = $this->db->prefix . 'cgss_insight'; |
||
22 | } |
||
23 | |||
24 | /** |
||
25 | * Get all rows from the insight table. |
||
26 | */ |
||
27 | public function all(): array |
||
28 | { |
||
29 | $sql = "SELECT * FROM {$this->table}"; |
||
30 | return $this->db->get_results($sql, ARRAY_A); |
||
0 ignored issues
–
show
|
|||
31 | } |
||
32 | |||
33 | /** |
||
34 | * Count rows in the insight table. |
||
35 | */ |
||
36 | public function count(): int |
||
37 | { |
||
38 | $sql = "SELECT COUNT(*) FROM {$this->table}"; |
||
39 | return (int) $this->db->get_var($sql); |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * Insert an insight row. |
||
44 | */ |
||
45 | public function insert(string $item, string $remark, int $id): bool |
||
46 | { |
||
47 | $result = $this->db->insert( |
||
48 | $this->table, |
||
49 | ['ID' => $id, 'item' => $item, 'remark' => $remark], |
||
50 | ['%d', '%s', '%s'] |
||
51 | ); |
||
52 | return $result !== false; |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * Update remark value by row id. |
||
57 | */ |
||
58 | public function updateRemark(int $id, string $remark): int |
||
59 | { |
||
60 | return $this->db->update( |
||
61 | $this->table, |
||
62 | ['remark' => $remark], |
||
63 | ['ID' => $id], |
||
64 | ['%s'], |
||
65 | ['%d'] |
||
66 | ); |
||
67 | } |
||
68 | } |
||
69 |
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