1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Win\Database\Orm\Traits; |
4
|
|
|
|
5
|
|
|
trait ReadTrait |
6
|
|
|
{ |
7
|
|
|
/** @var Select */ |
|
|
|
|
8
|
|
|
private $query; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Retorna o primeiro resultado da consulta |
12
|
|
|
*/ |
13
|
|
|
public function one() |
14
|
|
|
{ |
15
|
|
|
$rows = $this->query->execute(); |
16
|
|
|
|
17
|
|
|
return $this->mapModel($rows[0]); |
|
|
|
|
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Retorna todos os resultado da consulta |
22
|
|
|
*/ |
23
|
|
|
public function all() |
24
|
|
|
{ |
25
|
|
|
$rows = $this->query->execute(); |
26
|
|
|
$all = []; |
27
|
|
|
foreach ($rows as $row) { |
28
|
|
|
$all[] = $this->mapModel($row); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
return $all; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** @return int */ |
35
|
|
|
public function numRows() |
36
|
|
|
{ |
37
|
|
|
return $this->query->count(); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Define as colunas do resultado |
42
|
|
|
* @param string[] $columns |
43
|
|
|
* @return static |
44
|
|
|
*/ |
45
|
|
|
public function setColumns($columns) |
46
|
|
|
{ |
47
|
|
|
$this->query->columns = $columns; |
48
|
|
|
|
49
|
|
|
return $this; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Adiciona uma coluna do resultado |
54
|
|
|
* @param string $column |
55
|
|
|
* @return static |
56
|
|
|
*/ |
57
|
|
|
public function addColumn($column) |
58
|
|
|
{ |
59
|
|
|
$this->query->columns[] = $column; |
60
|
|
|
|
61
|
|
|
return $this; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Filtra pelo id |
66
|
|
|
* @param int $id |
67
|
|
|
* @return static |
68
|
|
|
*/ |
69
|
|
|
public function find($id) |
70
|
|
|
{ |
71
|
|
|
$this->filterBy('id', $id); |
72
|
|
|
|
73
|
|
|
return $this; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Filtra pelo campo |
78
|
|
|
* @param string $column |
79
|
|
|
* @param mixed $value |
80
|
|
|
* @return static |
81
|
|
|
*/ |
82
|
|
|
public function filterBy($column, $value) |
83
|
|
|
{ |
84
|
|
|
$this->filter($column, '=', $value); |
85
|
|
|
|
86
|
|
|
return $this; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Adiciona filtros para busca |
91
|
|
|
* @return static |
92
|
|
|
*/ |
93
|
|
|
public function filter($column, $operator, $value) |
94
|
|
|
{ |
95
|
|
|
$this->query->where->add($column, $operator, $value); |
96
|
|
|
|
97
|
|
|
return $this; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* Limita os resultados |
102
|
|
|
* @param int $limit |
103
|
|
|
* @return static |
104
|
|
|
*/ |
105
|
|
|
public function limit($limit) |
106
|
|
|
{ |
107
|
|
|
$this->query->limit->set($limit); |
108
|
|
|
|
109
|
|
|
return $this; |
110
|
|
|
} |
111
|
|
|
} |
112
|
|
|
|
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