forked from kvnZero/hyperf-APIJSON
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConditionEntity.php
More file actions
182 lines (156 loc) · 3.16 KB
/
ConditionEntity.php
File metadata and controls
182 lines (156 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<?php
namespace App\ApiJson\Entity;
class ConditionEntity
{
protected array $changeLog = [];
/**
* @var array
*/
protected array $where = [];
protected int $limit = 10;
protected int $offset = 0;
protected string $column = '*';
protected array $group = [];
protected array $order = [];
protected array $having = [];
protected string $procedure = "";
/**
* @param array $condition 条件
*/
public function __construct(protected array $condition, protected array $extendData = [])
{
}
public function getExtendData(): array
{
return $this->extendData;
}
public function setCondition(array $condition)
{
$this->log($condition);
$this->condition = $condition;
}
public function getCondition(): array
{
return $this->condition;
}
public function getQueryWhere(): array
{
return $this->where;
}
public function setQueryWhere(array $where)
{
$this->where = $where;
}
public function addQueryWhere(string $key, string $sql, array $bindArgs = [])
{
$this->where[$key] = [
'sql' => $sql,
'bind' => $bindArgs
];
}
/**
* @param string $column
*/
public function setColumn(string $column): void
{
$this->column = $column;
}
/**
* @param array $group
*/
public function setGroup(array $group): void
{
$this->group = $group;
}
/**
* @param array $having
*/
public function setHaving(array $having): void
{
$this->having = $having;
}
/**
* @param int $limit
*/
public function setLimit(int $limit): void
{
$this->limit = $limit;
}
/**
* @param int $offset
*/
public function setOffset(int $offset): void
{
$this->offset = $offset;
}
/**
* @param array $order
*/
public function setOrder(array $order): void
{
$this->order = $order;
}
/**
* @return string
*/
public function getColumn(): string
{
return $this->column;
}
/**
* @return array
*/
public function getGroup(): array
{
return $this->group;
}
/**
* @return array
*/
public function getHaving(): array
{
return $this->having;
}
/**
* @return int
*/
public function getLimit(): int
{
return $this->limit;
}
/**
* @return int
*/
public function getOffset(): int
{
return $this->offset;
}
/**
* @return array
*/
public function getOrder(): array
{
return $this->order;
}
/**
* @param string $procedure
*/
public function setProcedure(string $procedure): void
{
$this->procedure = $procedure;
}
/**
* @return string
*/
public function getProcedure(): string
{
return $this->procedure;
}
protected function log(array $condition)
{
$this->changeLog[] = [
'old' => $this->condition,
'new' => $condition
];
}
}