-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSelectInterface.php
More file actions
233 lines (216 loc) · 5.1 KB
/
SelectInterface.php
File metadata and controls
233 lines (216 loc) · 5.1 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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
<?php
/**
*
* This file is part of Aura for PHP.
*
* @license http://opensource.org/licenses/bsd-license.php BSD
*
*/
namespace Swoole\SqlQuery\Common;
use Swoole\SqlQuery\QueryInterface;
/**
*
* An interface for SELECT queries.
*
* @package Aura.SqlQuery
*
*/
interface SelectInterface extends QueryInterface, WhereInterface, OrderByInterface, LimitOffsetInterface
{
/**
*
* Sets the number of rows per page.
*
* @param int $paging The number of rows to page at.
*
* @return $this
*
*/
public function setPaging($paging);
/**
*
* Gets the number of rows per page.
*
* @return int The number of rows per page.
*
*/
public function getPaging();
/**
*
* Makes the select FOR UPDATE (or not).
*
* @param bool $enable Whether or not the SELECT is FOR UPDATE (default
* true).
*
* @return $this
*
*/
public function forUpdate($enable = true);
/**
*
* Makes the select DISTINCT (or not).
*
* @param bool $enable Whether or not the SELECT is DISTINCT (default
* true).
*
* @return $this
*
*/
public function distinct($enable = true);
/**
*
* Adds columns to the query.
*
* Multiple calls to cols() will append to the list of columns, not
* overwrite the previous columns.
*
* @param array $cols The column(s) to add to the query.
*
* @return $this
*
*/
public function cols(array $cols);
/**
*
* Adds a FROM element to the query; quotes the table name automatically.
*
* @param string $spec The table specification; "foo" or "foo AS bar".
*
* @return $this
*
*/
public function from($spec);
/**
*
* Adds a raw unquoted FROM element to the query; useful for adding FROM
* elements that are functions.
*
* @param string $spec The table specification, e.g. "function_name()".
*
* @return $this
*
*/
public function fromRaw($spec);
/**
*
* Adds an aliased sub-select to the query.
*
* @param string|Select $spec If a Select object, use as the sub-select;
* if a string, the sub-select string.
*
* @param string $name The alias name for the sub-select.
*
* @return $this
*
*/
public function fromSubSelect($spec, $name);
/**
*
* Adds a JOIN table and columns to the query.
*
* @param string $join The join type: inner, left, natural, etc.
*
* @param string $spec The table specification; "foo" or "foo AS bar".
*
* @param string $cond Join on this condition.
*
* @return $this
*
*/
public function join($join, $spec, $cond = null);
/**
*
* Adds a JOIN to an aliased subselect and columns to the query.
*
* @param string $join The join type: inner, left, natural, etc.
*
* @param string|Select $spec If a Select
* object, use as the sub-select; if a string, the sub-select
* command string.
*
* @param string $name The alias name for the sub-select.
*
* @param string $cond Join on this condition.
*
* @return $this
*
*/
public function joinSubSelect($join, $spec, $name, $cond = null);
/**
*
* Adds grouping to the query.
*
* @param array $spec The column(s) to group by.
*
* @return $this
*
*/
public function groupBy(array $spec);
/**
*
* Adds a HAVING condition to the query by AND; if a value is passed as
* the second param, it will be quoted and replaced into the condition
* wherever a question-mark appears.
*
* Array values are quoted and comma-separated.
*
* {{code: php
* // simplest but non-secure
* $select->having("COUNT(id) = $count");
*
* // secure
* $select->having('COUNT(id) = ?', $count);
*
* // equivalent security with named binding
* $select->having('COUNT(id) = :count');
* $select->bind('count', $count);
* }}
*
* @param string $cond The HAVING condition.
*
* @return $this
*
*/
public function having($cond);
/**
*
* Adds a HAVING condition to the query by AND; otherwise identical to
* `having()`.
*
* @param string $cond The HAVING condition.
*
* @return $this
*
* @see having()
*
*/
public function orHaving($cond);
/**
*
* Sets the limit and count by page number.
*
* @param int $page Limit results to this page number.
*
* @return $this
*
*/
public function page($page);
/**
*
* Takes the current select properties and retains them, then sets
* UNION for the next set of properties.
*
* @return $this
*
*/
public function union();
/**
*
* Takes the current select properties and retains them, then sets
* UNION ALL for the next set of properties.
*
* @return $this
*
*/
public function unionAll();
}