@@ -35,410 +35,410 @@ |
||
35 | 35 | * @psalm-taint-specialize |
36 | 36 | */ |
37 | 37 | interface IExpressionBuilder { |
38 | - /** |
|
39 | - * @since 9.0.0 |
|
40 | - */ |
|
41 | - public const EQ = ExpressionBuilder::EQ; |
|
42 | - /** |
|
43 | - * @since 9.0.0 |
|
44 | - */ |
|
45 | - public const NEQ = ExpressionBuilder::NEQ; |
|
46 | - /** |
|
47 | - * @since 9.0.0 |
|
48 | - */ |
|
49 | - public const LT = ExpressionBuilder::LT; |
|
50 | - /** |
|
51 | - * @since 9.0.0 |
|
52 | - */ |
|
53 | - public const LTE = ExpressionBuilder::LTE; |
|
54 | - /** |
|
55 | - * @since 9.0.0 |
|
56 | - */ |
|
57 | - public const GT = ExpressionBuilder::GT; |
|
58 | - /** |
|
59 | - * @since 9.0.0 |
|
60 | - */ |
|
61 | - public const GTE = ExpressionBuilder::GTE; |
|
38 | + /** |
|
39 | + * @since 9.0.0 |
|
40 | + */ |
|
41 | + public const EQ = ExpressionBuilder::EQ; |
|
42 | + /** |
|
43 | + * @since 9.0.0 |
|
44 | + */ |
|
45 | + public const NEQ = ExpressionBuilder::NEQ; |
|
46 | + /** |
|
47 | + * @since 9.0.0 |
|
48 | + */ |
|
49 | + public const LT = ExpressionBuilder::LT; |
|
50 | + /** |
|
51 | + * @since 9.0.0 |
|
52 | + */ |
|
53 | + public const LTE = ExpressionBuilder::LTE; |
|
54 | + /** |
|
55 | + * @since 9.0.0 |
|
56 | + */ |
|
57 | + public const GT = ExpressionBuilder::GT; |
|
58 | + /** |
|
59 | + * @since 9.0.0 |
|
60 | + */ |
|
61 | + public const GTE = ExpressionBuilder::GTE; |
|
62 | 62 | |
63 | - /** |
|
64 | - * Creates a conjunction of the given boolean expressions. |
|
65 | - * |
|
66 | - * Example: |
|
67 | - * |
|
68 | - * [php] |
|
69 | - * // (u.type = ?) AND (u.role = ?) |
|
70 | - * $expr->andX('u.type = ?', 'u.role = ?')); |
|
71 | - * |
|
72 | - * @param mixed ...$x Optional clause. Defaults = null, but requires |
|
73 | - * at least one defined when converting to string. |
|
74 | - * |
|
75 | - * @return \OCP\DB\QueryBuilder\ICompositeExpression |
|
76 | - * @since 8.2.0 |
|
77 | - * |
|
78 | - * @psalm-taint-sink sql $x |
|
79 | - */ |
|
80 | - public function andX(...$x): ICompositeExpression; |
|
63 | + /** |
|
64 | + * Creates a conjunction of the given boolean expressions. |
|
65 | + * |
|
66 | + * Example: |
|
67 | + * |
|
68 | + * [php] |
|
69 | + * // (u.type = ?) AND (u.role = ?) |
|
70 | + * $expr->andX('u.type = ?', 'u.role = ?')); |
|
71 | + * |
|
72 | + * @param mixed ...$x Optional clause. Defaults = null, but requires |
|
73 | + * at least one defined when converting to string. |
|
74 | + * |
|
75 | + * @return \OCP\DB\QueryBuilder\ICompositeExpression |
|
76 | + * @since 8.2.0 |
|
77 | + * |
|
78 | + * @psalm-taint-sink sql $x |
|
79 | + */ |
|
80 | + public function andX(...$x): ICompositeExpression; |
|
81 | 81 | |
82 | - /** |
|
83 | - * Creates a disjunction of the given boolean expressions. |
|
84 | - * |
|
85 | - * Example: |
|
86 | - * |
|
87 | - * [php] |
|
88 | - * // (u.type = ?) OR (u.role = ?) |
|
89 | - * $qb->where($qb->expr()->orX('u.type = ?', 'u.role = ?')); |
|
90 | - * |
|
91 | - * @param mixed ...$x Optional clause. Defaults = null, but requires |
|
92 | - * at least one defined when converting to string. |
|
93 | - * |
|
94 | - * @return \OCP\DB\QueryBuilder\ICompositeExpression |
|
95 | - * @since 8.2.0 |
|
96 | - * |
|
97 | - * @psalm-taint-sink sql $x |
|
98 | - */ |
|
99 | - public function orX(...$x): ICompositeExpression; |
|
82 | + /** |
|
83 | + * Creates a disjunction of the given boolean expressions. |
|
84 | + * |
|
85 | + * Example: |
|
86 | + * |
|
87 | + * [php] |
|
88 | + * // (u.type = ?) OR (u.role = ?) |
|
89 | + * $qb->where($qb->expr()->orX('u.type = ?', 'u.role = ?')); |
|
90 | + * |
|
91 | + * @param mixed ...$x Optional clause. Defaults = null, but requires |
|
92 | + * at least one defined when converting to string. |
|
93 | + * |
|
94 | + * @return \OCP\DB\QueryBuilder\ICompositeExpression |
|
95 | + * @since 8.2.0 |
|
96 | + * |
|
97 | + * @psalm-taint-sink sql $x |
|
98 | + */ |
|
99 | + public function orX(...$x): ICompositeExpression; |
|
100 | 100 | |
101 | - /** |
|
102 | - * Creates a comparison expression. |
|
103 | - * |
|
104 | - * @param mixed $x The left expression. |
|
105 | - * @param string $operator One of the IExpressionBuilder::* constants. |
|
106 | - * @param mixed $y The right expression. |
|
107 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
108 | - * required when comparing text fields for oci compatibility |
|
109 | - * |
|
110 | - * @return string |
|
111 | - * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
112 | - * |
|
113 | - * @psalm-taint-sink sql $x |
|
114 | - * @psalm-taint-sink sql $operator |
|
115 | - * @psalm-taint-sink sql $y |
|
116 | - * @psalm-taint-sink sql $type |
|
117 | - */ |
|
118 | - public function comparison($x, string $operator, $y, $type = null): string; |
|
101 | + /** |
|
102 | + * Creates a comparison expression. |
|
103 | + * |
|
104 | + * @param mixed $x The left expression. |
|
105 | + * @param string $operator One of the IExpressionBuilder::* constants. |
|
106 | + * @param mixed $y The right expression. |
|
107 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
108 | + * required when comparing text fields for oci compatibility |
|
109 | + * |
|
110 | + * @return string |
|
111 | + * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
112 | + * |
|
113 | + * @psalm-taint-sink sql $x |
|
114 | + * @psalm-taint-sink sql $operator |
|
115 | + * @psalm-taint-sink sql $y |
|
116 | + * @psalm-taint-sink sql $type |
|
117 | + */ |
|
118 | + public function comparison($x, string $operator, $y, $type = null): string; |
|
119 | 119 | |
120 | - /** |
|
121 | - * Creates an equality comparison expression with the given arguments. |
|
122 | - * |
|
123 | - * First argument is considered the left expression and the second is the right expression. |
|
124 | - * When converted to string, it will generated a <left expr> = <right expr>. Example: |
|
125 | - * |
|
126 | - * [php] |
|
127 | - * // u.id = ? |
|
128 | - * $expr->eq('u.id', '?'); |
|
129 | - * |
|
130 | - * @param mixed $x The left expression. |
|
131 | - * @param mixed $y The right expression. |
|
132 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
133 | - * required when comparing text fields for oci compatibility |
|
134 | - * |
|
135 | - * @return string |
|
136 | - * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
137 | - * |
|
138 | - * @psalm-taint-sink sql $x |
|
139 | - * @psalm-taint-sink sql $y |
|
140 | - * @psalm-taint-sink sql $type |
|
141 | - */ |
|
142 | - public function eq($x, $y, $type = null): string; |
|
120 | + /** |
|
121 | + * Creates an equality comparison expression with the given arguments. |
|
122 | + * |
|
123 | + * First argument is considered the left expression and the second is the right expression. |
|
124 | + * When converted to string, it will generated a <left expr> = <right expr>. Example: |
|
125 | + * |
|
126 | + * [php] |
|
127 | + * // u.id = ? |
|
128 | + * $expr->eq('u.id', '?'); |
|
129 | + * |
|
130 | + * @param mixed $x The left expression. |
|
131 | + * @param mixed $y The right expression. |
|
132 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
133 | + * required when comparing text fields for oci compatibility |
|
134 | + * |
|
135 | + * @return string |
|
136 | + * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
137 | + * |
|
138 | + * @psalm-taint-sink sql $x |
|
139 | + * @psalm-taint-sink sql $y |
|
140 | + * @psalm-taint-sink sql $type |
|
141 | + */ |
|
142 | + public function eq($x, $y, $type = null): string; |
|
143 | 143 | |
144 | - /** |
|
145 | - * Creates a non equality comparison expression with the given arguments. |
|
146 | - * First argument is considered the left expression and the second is the right expression. |
|
147 | - * When converted to string, it will generated a <left expr> <> <right expr>. Example: |
|
148 | - * |
|
149 | - * [php] |
|
150 | - * // u.id <> 1 |
|
151 | - * $q->where($q->expr()->neq('u.id', '1')); |
|
152 | - * |
|
153 | - * @param mixed $x The left expression. |
|
154 | - * @param mixed $y The right expression. |
|
155 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
156 | - * required when comparing text fields for oci compatibility |
|
157 | - * |
|
158 | - * @return string |
|
159 | - * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
160 | - * |
|
161 | - * @psalm-taint-sink sql $x |
|
162 | - * @psalm-taint-sink sql $y |
|
163 | - * @psalm-taint-sink sql $type |
|
164 | - */ |
|
165 | - public function neq($x, $y, $type = null): string; |
|
144 | + /** |
|
145 | + * Creates a non equality comparison expression with the given arguments. |
|
146 | + * First argument is considered the left expression and the second is the right expression. |
|
147 | + * When converted to string, it will generated a <left expr> <> <right expr>. Example: |
|
148 | + * |
|
149 | + * [php] |
|
150 | + * // u.id <> 1 |
|
151 | + * $q->where($q->expr()->neq('u.id', '1')); |
|
152 | + * |
|
153 | + * @param mixed $x The left expression. |
|
154 | + * @param mixed $y The right expression. |
|
155 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
156 | + * required when comparing text fields for oci compatibility |
|
157 | + * |
|
158 | + * @return string |
|
159 | + * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
160 | + * |
|
161 | + * @psalm-taint-sink sql $x |
|
162 | + * @psalm-taint-sink sql $y |
|
163 | + * @psalm-taint-sink sql $type |
|
164 | + */ |
|
165 | + public function neq($x, $y, $type = null): string; |
|
166 | 166 | |
167 | - /** |
|
168 | - * Creates a lower-than comparison expression with the given arguments. |
|
169 | - * First argument is considered the left expression and the second is the right expression. |
|
170 | - * When converted to string, it will generated a <left expr> < <right expr>. Example: |
|
171 | - * |
|
172 | - * [php] |
|
173 | - * // u.id < ? |
|
174 | - * $q->where($q->expr()->lt('u.id', '?')); |
|
175 | - * |
|
176 | - * @param mixed $x The left expression. |
|
177 | - * @param mixed $y The right expression. |
|
178 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
179 | - * required when comparing text fields for oci compatibility |
|
180 | - * |
|
181 | - * @return string |
|
182 | - * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
183 | - * |
|
184 | - * @psalm-taint-sink sql $x |
|
185 | - * @psalm-taint-sink sql $y |
|
186 | - * @psalm-taint-sink sql $type |
|
187 | - */ |
|
188 | - public function lt($x, $y, $type = null): string; |
|
167 | + /** |
|
168 | + * Creates a lower-than comparison expression with the given arguments. |
|
169 | + * First argument is considered the left expression and the second is the right expression. |
|
170 | + * When converted to string, it will generated a <left expr> < <right expr>. Example: |
|
171 | + * |
|
172 | + * [php] |
|
173 | + * // u.id < ? |
|
174 | + * $q->where($q->expr()->lt('u.id', '?')); |
|
175 | + * |
|
176 | + * @param mixed $x The left expression. |
|
177 | + * @param mixed $y The right expression. |
|
178 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
179 | + * required when comparing text fields for oci compatibility |
|
180 | + * |
|
181 | + * @return string |
|
182 | + * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
183 | + * |
|
184 | + * @psalm-taint-sink sql $x |
|
185 | + * @psalm-taint-sink sql $y |
|
186 | + * @psalm-taint-sink sql $type |
|
187 | + */ |
|
188 | + public function lt($x, $y, $type = null): string; |
|
189 | 189 | |
190 | - /** |
|
191 | - * Creates a lower-than-equal comparison expression with the given arguments. |
|
192 | - * First argument is considered the left expression and the second is the right expression. |
|
193 | - * When converted to string, it will generated a <left expr> <= <right expr>. Example: |
|
194 | - * |
|
195 | - * [php] |
|
196 | - * // u.id <= ? |
|
197 | - * $q->where($q->expr()->lte('u.id', '?')); |
|
198 | - * |
|
199 | - * @param mixed $x The left expression. |
|
200 | - * @param mixed $y The right expression. |
|
201 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
202 | - * required when comparing text fields for oci compatibility |
|
203 | - * |
|
204 | - * @return string |
|
205 | - * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
206 | - * |
|
207 | - * @psalm-taint-sink sql $x |
|
208 | - * @psalm-taint-sink sql $y |
|
209 | - * @psalm-taint-sink sql $type |
|
210 | - */ |
|
211 | - public function lte($x, $y, $type = null): string; |
|
190 | + /** |
|
191 | + * Creates a lower-than-equal comparison expression with the given arguments. |
|
192 | + * First argument is considered the left expression and the second is the right expression. |
|
193 | + * When converted to string, it will generated a <left expr> <= <right expr>. Example: |
|
194 | + * |
|
195 | + * [php] |
|
196 | + * // u.id <= ? |
|
197 | + * $q->where($q->expr()->lte('u.id', '?')); |
|
198 | + * |
|
199 | + * @param mixed $x The left expression. |
|
200 | + * @param mixed $y The right expression. |
|
201 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
202 | + * required when comparing text fields for oci compatibility |
|
203 | + * |
|
204 | + * @return string |
|
205 | + * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
206 | + * |
|
207 | + * @psalm-taint-sink sql $x |
|
208 | + * @psalm-taint-sink sql $y |
|
209 | + * @psalm-taint-sink sql $type |
|
210 | + */ |
|
211 | + public function lte($x, $y, $type = null): string; |
|
212 | 212 | |
213 | - /** |
|
214 | - * Creates a greater-than comparison expression with the given arguments. |
|
215 | - * First argument is considered the left expression and the second is the right expression. |
|
216 | - * When converted to string, it will generated a <left expr> > <right expr>. Example: |
|
217 | - * |
|
218 | - * [php] |
|
219 | - * // u.id > ? |
|
220 | - * $q->where($q->expr()->gt('u.id', '?')); |
|
221 | - * |
|
222 | - * @param mixed $x The left expression. |
|
223 | - * @param mixed $y The right expression. |
|
224 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
225 | - * required when comparing text fields for oci compatibility |
|
226 | - * |
|
227 | - * @return string |
|
228 | - * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
229 | - * |
|
230 | - * @psalm-taint-sink sql $x |
|
231 | - * @psalm-taint-sink sql $y |
|
232 | - * @psalm-taint-sink sql $type |
|
233 | - */ |
|
234 | - public function gt($x, $y, $type = null): string; |
|
213 | + /** |
|
214 | + * Creates a greater-than comparison expression with the given arguments. |
|
215 | + * First argument is considered the left expression and the second is the right expression. |
|
216 | + * When converted to string, it will generated a <left expr> > <right expr>. Example: |
|
217 | + * |
|
218 | + * [php] |
|
219 | + * // u.id > ? |
|
220 | + * $q->where($q->expr()->gt('u.id', '?')); |
|
221 | + * |
|
222 | + * @param mixed $x The left expression. |
|
223 | + * @param mixed $y The right expression. |
|
224 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
225 | + * required when comparing text fields for oci compatibility |
|
226 | + * |
|
227 | + * @return string |
|
228 | + * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
229 | + * |
|
230 | + * @psalm-taint-sink sql $x |
|
231 | + * @psalm-taint-sink sql $y |
|
232 | + * @psalm-taint-sink sql $type |
|
233 | + */ |
|
234 | + public function gt($x, $y, $type = null): string; |
|
235 | 235 | |
236 | - /** |
|
237 | - * Creates a greater-than-equal comparison expression with the given arguments. |
|
238 | - * First argument is considered the left expression and the second is the right expression. |
|
239 | - * When converted to string, it will generated a <left expr> >= <right expr>. Example: |
|
240 | - * |
|
241 | - * [php] |
|
242 | - * // u.id >= ? |
|
243 | - * $q->where($q->expr()->gte('u.id', '?')); |
|
244 | - * |
|
245 | - * @param mixed $x The left expression. |
|
246 | - * @param mixed $y The right expression. |
|
247 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
248 | - * required when comparing text fields for oci compatibility |
|
249 | - * |
|
250 | - * @return string |
|
251 | - * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
252 | - * |
|
253 | - * @psalm-taint-sink sql $x |
|
254 | - * @psalm-taint-sink sql $y |
|
255 | - * @psalm-taint-sink sql $type |
|
256 | - */ |
|
257 | - public function gte($x, $y, $type = null): string; |
|
236 | + /** |
|
237 | + * Creates a greater-than-equal comparison expression with the given arguments. |
|
238 | + * First argument is considered the left expression and the second is the right expression. |
|
239 | + * When converted to string, it will generated a <left expr> >= <right expr>. Example: |
|
240 | + * |
|
241 | + * [php] |
|
242 | + * // u.id >= ? |
|
243 | + * $q->where($q->expr()->gte('u.id', '?')); |
|
244 | + * |
|
245 | + * @param mixed $x The left expression. |
|
246 | + * @param mixed $y The right expression. |
|
247 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
248 | + * required when comparing text fields for oci compatibility |
|
249 | + * |
|
250 | + * @return string |
|
251 | + * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
252 | + * |
|
253 | + * @psalm-taint-sink sql $x |
|
254 | + * @psalm-taint-sink sql $y |
|
255 | + * @psalm-taint-sink sql $type |
|
256 | + */ |
|
257 | + public function gte($x, $y, $type = null): string; |
|
258 | 258 | |
259 | - /** |
|
260 | - * Creates an IS NULL expression with the given arguments. |
|
261 | - * |
|
262 | - * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be restricted by IS NULL. |
|
263 | - * |
|
264 | - * @return string |
|
265 | - * @since 8.2.0 |
|
266 | - * |
|
267 | - * @psalm-taint-sink sql $x |
|
268 | - */ |
|
269 | - public function isNull($x): string; |
|
259 | + /** |
|
260 | + * Creates an IS NULL expression with the given arguments. |
|
261 | + * |
|
262 | + * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be restricted by IS NULL. |
|
263 | + * |
|
264 | + * @return string |
|
265 | + * @since 8.2.0 |
|
266 | + * |
|
267 | + * @psalm-taint-sink sql $x |
|
268 | + */ |
|
269 | + public function isNull($x): string; |
|
270 | 270 | |
271 | - /** |
|
272 | - * Creates an IS NOT NULL expression with the given arguments. |
|
273 | - * |
|
274 | - * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be restricted by IS NOT NULL. |
|
275 | - * |
|
276 | - * @return string |
|
277 | - * @since 8.2.0 |
|
278 | - * |
|
279 | - * @psalm-taint-sink sql $x |
|
280 | - */ |
|
281 | - public function isNotNull($x): string; |
|
271 | + /** |
|
272 | + * Creates an IS NOT NULL expression with the given arguments. |
|
273 | + * |
|
274 | + * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be restricted by IS NOT NULL. |
|
275 | + * |
|
276 | + * @return string |
|
277 | + * @since 8.2.0 |
|
278 | + * |
|
279 | + * @psalm-taint-sink sql $x |
|
280 | + */ |
|
281 | + public function isNotNull($x): string; |
|
282 | 282 | |
283 | - /** |
|
284 | - * Creates a LIKE() comparison expression with the given arguments. |
|
285 | - * |
|
286 | - * @param ILiteral|IParameter|IQueryFunction|string $x Field in string format to be inspected by LIKE() comparison. |
|
287 | - * @param mixed $y Argument to be used in LIKE() comparison. |
|
288 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
289 | - * required when comparing text fields for oci compatibility |
|
290 | - * |
|
291 | - * @return string |
|
292 | - * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
293 | - * |
|
294 | - * @psalm-taint-sink sql $x |
|
295 | - * @psalm-taint-sink sql $y |
|
296 | - * @psalm-taint-sink sql $type |
|
297 | - */ |
|
298 | - public function like($x, $y, $type = null): string; |
|
283 | + /** |
|
284 | + * Creates a LIKE() comparison expression with the given arguments. |
|
285 | + * |
|
286 | + * @param ILiteral|IParameter|IQueryFunction|string $x Field in string format to be inspected by LIKE() comparison. |
|
287 | + * @param mixed $y Argument to be used in LIKE() comparison. |
|
288 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
289 | + * required when comparing text fields for oci compatibility |
|
290 | + * |
|
291 | + * @return string |
|
292 | + * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
293 | + * |
|
294 | + * @psalm-taint-sink sql $x |
|
295 | + * @psalm-taint-sink sql $y |
|
296 | + * @psalm-taint-sink sql $type |
|
297 | + */ |
|
298 | + public function like($x, $y, $type = null): string; |
|
299 | 299 | |
300 | - /** |
|
301 | - * Creates a NOT LIKE() comparison expression with the given arguments. |
|
302 | - * |
|
303 | - * @param ILiteral|IParameter|IQueryFunction|string $x Field in string format to be inspected by NOT LIKE() comparison. |
|
304 | - * @param mixed $y Argument to be used in NOT LIKE() comparison. |
|
305 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
306 | - * required when comparing text fields for oci compatibility |
|
307 | - * |
|
308 | - * @return string |
|
309 | - * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
310 | - * |
|
311 | - * @psalm-taint-sink sql $x |
|
312 | - * @psalm-taint-sink sql $y |
|
313 | - * @psalm-taint-sink sql $type |
|
314 | - */ |
|
315 | - public function notLike($x, $y, $type = null): string; |
|
300 | + /** |
|
301 | + * Creates a NOT LIKE() comparison expression with the given arguments. |
|
302 | + * |
|
303 | + * @param ILiteral|IParameter|IQueryFunction|string $x Field in string format to be inspected by NOT LIKE() comparison. |
|
304 | + * @param mixed $y Argument to be used in NOT LIKE() comparison. |
|
305 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
306 | + * required when comparing text fields for oci compatibility |
|
307 | + * |
|
308 | + * @return string |
|
309 | + * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
310 | + * |
|
311 | + * @psalm-taint-sink sql $x |
|
312 | + * @psalm-taint-sink sql $y |
|
313 | + * @psalm-taint-sink sql $type |
|
314 | + */ |
|
315 | + public function notLike($x, $y, $type = null): string; |
|
316 | 316 | |
317 | - /** |
|
318 | - * Creates a ILIKE() comparison expression with the given arguments. |
|
319 | - * |
|
320 | - * @param string $x Field in string format to be inspected by ILIKE() comparison. |
|
321 | - * @param mixed $y Argument to be used in ILIKE() comparison. |
|
322 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
323 | - * required when comparing text fields for oci compatibility |
|
324 | - * |
|
325 | - * @return string |
|
326 | - * @since 9.0.0 |
|
327 | - * |
|
328 | - * @psalm-taint-sink sql $x |
|
329 | - * @psalm-taint-sink sql $y |
|
330 | - * @psalm-taint-sink sql $type |
|
331 | - */ |
|
332 | - public function iLike($x, $y, $type = null): string; |
|
317 | + /** |
|
318 | + * Creates a ILIKE() comparison expression with the given arguments. |
|
319 | + * |
|
320 | + * @param string $x Field in string format to be inspected by ILIKE() comparison. |
|
321 | + * @param mixed $y Argument to be used in ILIKE() comparison. |
|
322 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
323 | + * required when comparing text fields for oci compatibility |
|
324 | + * |
|
325 | + * @return string |
|
326 | + * @since 9.0.0 |
|
327 | + * |
|
328 | + * @psalm-taint-sink sql $x |
|
329 | + * @psalm-taint-sink sql $y |
|
330 | + * @psalm-taint-sink sql $type |
|
331 | + */ |
|
332 | + public function iLike($x, $y, $type = null): string; |
|
333 | 333 | |
334 | - /** |
|
335 | - * Creates a IN () comparison expression with the given arguments. |
|
336 | - * |
|
337 | - * @param ILiteral|IParameter|IQueryFunction|string $x The field in string format to be inspected by IN() comparison. |
|
338 | - * @param ILiteral|IParameter|IQueryFunction|string|array $y The placeholder or the array of values to be used by IN() comparison. |
|
339 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
340 | - * required when comparing text fields for oci compatibility |
|
341 | - * |
|
342 | - * @return string |
|
343 | - * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
344 | - * |
|
345 | - * @psalm-taint-sink sql $x |
|
346 | - * @psalm-taint-sink sql $y |
|
347 | - * @psalm-taint-sink sql $type |
|
348 | - */ |
|
349 | - public function in($x, $y, $type = null): string; |
|
334 | + /** |
|
335 | + * Creates a IN () comparison expression with the given arguments. |
|
336 | + * |
|
337 | + * @param ILiteral|IParameter|IQueryFunction|string $x The field in string format to be inspected by IN() comparison. |
|
338 | + * @param ILiteral|IParameter|IQueryFunction|string|array $y The placeholder or the array of values to be used by IN() comparison. |
|
339 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
340 | + * required when comparing text fields for oci compatibility |
|
341 | + * |
|
342 | + * @return string |
|
343 | + * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
344 | + * |
|
345 | + * @psalm-taint-sink sql $x |
|
346 | + * @psalm-taint-sink sql $y |
|
347 | + * @psalm-taint-sink sql $type |
|
348 | + */ |
|
349 | + public function in($x, $y, $type = null): string; |
|
350 | 350 | |
351 | - /** |
|
352 | - * Creates a NOT IN () comparison expression with the given arguments. |
|
353 | - * |
|
354 | - * @param ILiteral|IParameter|IQueryFunction|string $x The field in string format to be inspected by NOT IN() comparison. |
|
355 | - * @param ILiteral|IParameter|IQueryFunction|string|array $y The placeholder or the array of values to be used by NOT IN() comparison. |
|
356 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
357 | - * required when comparing text fields for oci compatibility |
|
358 | - * |
|
359 | - * @return string |
|
360 | - * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
361 | - * |
|
362 | - * @psalm-taint-sink sql $x |
|
363 | - * @psalm-taint-sink sql $y |
|
364 | - * @psalm-taint-sink sql $type |
|
365 | - */ |
|
366 | - public function notIn($x, $y, $type = null): string; |
|
351 | + /** |
|
352 | + * Creates a NOT IN () comparison expression with the given arguments. |
|
353 | + * |
|
354 | + * @param ILiteral|IParameter|IQueryFunction|string $x The field in string format to be inspected by NOT IN() comparison. |
|
355 | + * @param ILiteral|IParameter|IQueryFunction|string|array $y The placeholder or the array of values to be used by NOT IN() comparison. |
|
356 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
357 | + * required when comparing text fields for oci compatibility |
|
358 | + * |
|
359 | + * @return string |
|
360 | + * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
361 | + * |
|
362 | + * @psalm-taint-sink sql $x |
|
363 | + * @psalm-taint-sink sql $y |
|
364 | + * @psalm-taint-sink sql $type |
|
365 | + */ |
|
366 | + public function notIn($x, $y, $type = null): string; |
|
367 | 367 | |
368 | - /** |
|
369 | - * Creates a $x = '' statement, because Oracle needs a different check |
|
370 | - * |
|
371 | - * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be inspected by the comparison. |
|
372 | - * @return string |
|
373 | - * @since 13.0.0 |
|
374 | - * |
|
375 | - * @psalm-taint-sink sql $x |
|
376 | - */ |
|
377 | - public function emptyString($x): string; |
|
368 | + /** |
|
369 | + * Creates a $x = '' statement, because Oracle needs a different check |
|
370 | + * |
|
371 | + * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be inspected by the comparison. |
|
372 | + * @return string |
|
373 | + * @since 13.0.0 |
|
374 | + * |
|
375 | + * @psalm-taint-sink sql $x |
|
376 | + */ |
|
377 | + public function emptyString($x): string; |
|
378 | 378 | |
379 | - /** |
|
380 | - * Creates a `$x <> ''` statement, because Oracle needs a different check |
|
381 | - * |
|
382 | - * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be inspected by the comparison. |
|
383 | - * @return string |
|
384 | - * @since 13.0.0 |
|
385 | - * |
|
386 | - * @psalm-taint-sink sql $x |
|
387 | - */ |
|
388 | - public function nonEmptyString($x): string; |
|
379 | + /** |
|
380 | + * Creates a `$x <> ''` statement, because Oracle needs a different check |
|
381 | + * |
|
382 | + * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be inspected by the comparison. |
|
383 | + * @return string |
|
384 | + * @since 13.0.0 |
|
385 | + * |
|
386 | + * @psalm-taint-sink sql $x |
|
387 | + */ |
|
388 | + public function nonEmptyString($x): string; |
|
389 | 389 | |
390 | 390 | |
391 | - /** |
|
392 | - * Creates a bitwise AND comparison |
|
393 | - * |
|
394 | - * @param string|ILiteral $x The field or value to check |
|
395 | - * @param int $y Bitmap that must be set |
|
396 | - * @return IQueryFunction |
|
397 | - * @since 12.0.0 |
|
398 | - * |
|
399 | - * @psalm-taint-sink sql $x |
|
400 | - * @psalm-taint-sink sql $y |
|
401 | - */ |
|
402 | - public function bitwiseAnd($x, int $y): IQueryFunction; |
|
391 | + /** |
|
392 | + * Creates a bitwise AND comparison |
|
393 | + * |
|
394 | + * @param string|ILiteral $x The field or value to check |
|
395 | + * @param int $y Bitmap that must be set |
|
396 | + * @return IQueryFunction |
|
397 | + * @since 12.0.0 |
|
398 | + * |
|
399 | + * @psalm-taint-sink sql $x |
|
400 | + * @psalm-taint-sink sql $y |
|
401 | + */ |
|
402 | + public function bitwiseAnd($x, int $y): IQueryFunction; |
|
403 | 403 | |
404 | - /** |
|
405 | - * Creates a bitwise OR comparison |
|
406 | - * |
|
407 | - * @param string|ILiteral $x The field or value to check |
|
408 | - * @param int $y Bitmap that must be set |
|
409 | - * @return IQueryFunction |
|
410 | - * @since 12.0.0 |
|
411 | - * |
|
412 | - * @psalm-taint-sink sql $x |
|
413 | - * @psalm-taint-sink sql $y |
|
414 | - */ |
|
415 | - public function bitwiseOr($x, int $y): IQueryFunction; |
|
404 | + /** |
|
405 | + * Creates a bitwise OR comparison |
|
406 | + * |
|
407 | + * @param string|ILiteral $x The field or value to check |
|
408 | + * @param int $y Bitmap that must be set |
|
409 | + * @return IQueryFunction |
|
410 | + * @since 12.0.0 |
|
411 | + * |
|
412 | + * @psalm-taint-sink sql $x |
|
413 | + * @psalm-taint-sink sql $y |
|
414 | + */ |
|
415 | + public function bitwiseOr($x, int $y): IQueryFunction; |
|
416 | 416 | |
417 | - /** |
|
418 | - * Quotes a given input parameter. |
|
419 | - * |
|
420 | - * @param mixed $input The parameter to be quoted. |
|
421 | - * @param int $type One of the IQueryBuilder::PARAM_* constants |
|
422 | - * |
|
423 | - * @return ILiteral |
|
424 | - * @since 8.2.0 |
|
425 | - * |
|
426 | - * @psalm-taint-sink sql $input |
|
427 | - * @psalm-taint-sink sql $type |
|
428 | - */ |
|
429 | - public function literal($input, $type = IQueryBuilder::PARAM_STR): ILiteral; |
|
417 | + /** |
|
418 | + * Quotes a given input parameter. |
|
419 | + * |
|
420 | + * @param mixed $input The parameter to be quoted. |
|
421 | + * @param int $type One of the IQueryBuilder::PARAM_* constants |
|
422 | + * |
|
423 | + * @return ILiteral |
|
424 | + * @since 8.2.0 |
|
425 | + * |
|
426 | + * @psalm-taint-sink sql $input |
|
427 | + * @psalm-taint-sink sql $type |
|
428 | + */ |
|
429 | + public function literal($input, $type = IQueryBuilder::PARAM_STR): ILiteral; |
|
430 | 430 | |
431 | - /** |
|
432 | - * Returns a IQueryFunction that casts the column to the given type |
|
433 | - * |
|
434 | - * @param string|IQueryFunction $column |
|
435 | - * @param mixed $type One of IQueryBuilder::PARAM_* |
|
436 | - * @psalm-param IQueryBuilder::PARAM_* $type |
|
437 | - * @return IQueryFunction |
|
438 | - * @since 9.0.0 |
|
439 | - * |
|
440 | - * @psalm-taint-sink sql $column |
|
441 | - * @psalm-taint-sink sql $type |
|
442 | - */ |
|
443 | - public function castColumn($column, $type): IQueryFunction; |
|
431 | + /** |
|
432 | + * Returns a IQueryFunction that casts the column to the given type |
|
433 | + * |
|
434 | + * @param string|IQueryFunction $column |
|
435 | + * @param mixed $type One of IQueryBuilder::PARAM_* |
|
436 | + * @psalm-param IQueryBuilder::PARAM_* $type |
|
437 | + * @return IQueryFunction |
|
438 | + * @since 9.0.0 |
|
439 | + * |
|
440 | + * @psalm-taint-sink sql $column |
|
441 | + * @psalm-taint-sink sql $type |
|
442 | + */ |
|
443 | + public function castColumn($column, $type): IQueryFunction; |
|
444 | 444 | } |
@@ -32,43 +32,43 @@ |
||
32 | 32 | |
33 | 33 | class MySqlExpressionBuilder extends ExpressionBuilder { |
34 | 34 | |
35 | - /** @var string */ |
|
36 | - protected $collation; |
|
35 | + /** @var string */ |
|
36 | + protected $collation; |
|
37 | 37 | |
38 | - /** |
|
39 | - * @param ConnectionAdapter $connection |
|
40 | - * @param IQueryBuilder $queryBuilder |
|
41 | - */ |
|
42 | - public function __construct(ConnectionAdapter $connection, IQueryBuilder $queryBuilder) { |
|
43 | - parent::__construct($connection, $queryBuilder); |
|
38 | + /** |
|
39 | + * @param ConnectionAdapter $connection |
|
40 | + * @param IQueryBuilder $queryBuilder |
|
41 | + */ |
|
42 | + public function __construct(ConnectionAdapter $connection, IQueryBuilder $queryBuilder) { |
|
43 | + parent::__construct($connection, $queryBuilder); |
|
44 | 44 | |
45 | - $params = $connection->getInner()->getParams(); |
|
46 | - $this->collation = $params['collation'] ?? (($params['charset'] ?? 'utf8') . '_general_ci'); |
|
47 | - } |
|
45 | + $params = $connection->getInner()->getParams(); |
|
46 | + $this->collation = $params['collation'] ?? (($params['charset'] ?? 'utf8') . '_general_ci'); |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * @inheritdoc |
|
51 | - */ |
|
52 | - public function iLike($x, $y, $type = null): string { |
|
53 | - $x = $this->helper->quoteColumnName($x); |
|
54 | - $y = $this->helper->quoteColumnName($y); |
|
55 | - return $this->expressionBuilder->comparison($x, ' COLLATE ' . $this->collation . ' LIKE', $y); |
|
56 | - } |
|
49 | + /** |
|
50 | + * @inheritdoc |
|
51 | + */ |
|
52 | + public function iLike($x, $y, $type = null): string { |
|
53 | + $x = $this->helper->quoteColumnName($x); |
|
54 | + $y = $this->helper->quoteColumnName($y); |
|
55 | + return $this->expressionBuilder->comparison($x, ' COLLATE ' . $this->collation . ' LIKE', $y); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * Returns a IQueryFunction that casts the column to the given type |
|
60 | - * |
|
61 | - * @param string|IQueryFunction $column |
|
62 | - * @param mixed $type One of IQueryBuilder::PARAM_* |
|
63 | - * @psalm-param IQueryBuilder::PARAM_* $type |
|
64 | - * @return IQueryFunction |
|
65 | - */ |
|
66 | - public function castColumn($column, $type): IQueryFunction { |
|
67 | - switch ($type) { |
|
68 | - case IQueryBuilder::PARAM_STR: |
|
69 | - return new QueryFunction('CAST(' . $this->helper->quoteColumnName($column) . ' AS CHAR)'); |
|
70 | - default: |
|
71 | - return parent::castColumn($column, $type); |
|
72 | - } |
|
73 | - } |
|
58 | + /** |
|
59 | + * Returns a IQueryFunction that casts the column to the given type |
|
60 | + * |
|
61 | + * @param string|IQueryFunction $column |
|
62 | + * @param mixed $type One of IQueryBuilder::PARAM_* |
|
63 | + * @psalm-param IQueryBuilder::PARAM_* $type |
|
64 | + * @return IQueryFunction |
|
65 | + */ |
|
66 | + public function castColumn($column, $type): IQueryFunction { |
|
67 | + switch ($type) { |
|
68 | + case IQueryBuilder::PARAM_STR: |
|
69 | + return new QueryFunction('CAST(' . $this->helper->quoteColumnName($column) . ' AS CHAR)'); |
|
70 | + default: |
|
71 | + return parent::castColumn($column, $type); |
|
72 | + } |
|
73 | + } |
|
74 | 74 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | parent::__construct($connection, $queryBuilder); |
44 | 44 | |
45 | 45 | $params = $connection->getInner()->getParams(); |
46 | - $this->collation = $params['collation'] ?? (($params['charset'] ?? 'utf8') . '_general_ci'); |
|
46 | + $this->collation = $params['collation'] ?? (($params['charset'] ?? 'utf8').'_general_ci'); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | public function iLike($x, $y, $type = null): string { |
53 | 53 | $x = $this->helper->quoteColumnName($x); |
54 | 54 | $y = $this->helper->quoteColumnName($y); |
55 | - return $this->expressionBuilder->comparison($x, ' COLLATE ' . $this->collation . ' LIKE', $y); |
|
55 | + return $this->expressionBuilder->comparison($x, ' COLLATE '.$this->collation.' LIKE', $y); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | public function castColumn($column, $type): IQueryFunction { |
67 | 67 | switch ($type) { |
68 | 68 | case IQueryBuilder::PARAM_STR: |
69 | - return new QueryFunction('CAST(' . $this->helper->quoteColumnName($column) . ' AS CHAR)'); |
|
69 | + return new QueryFunction('CAST('.$this->helper->quoteColumnName($column).' AS CHAR)'); |
|
70 | 70 | default: |
71 | 71 | return parent::castColumn($column, $type); |
72 | 72 | } |
@@ -30,31 +30,31 @@ |
||
30 | 30 | |
31 | 31 | class PgSqlExpressionBuilder extends ExpressionBuilder { |
32 | 32 | |
33 | - /** |
|
34 | - * Returns a IQueryFunction that casts the column to the given type |
|
35 | - * |
|
36 | - * @param string|IQueryFunction $column |
|
37 | - * @param mixed $type One of IQueryBuilder::PARAM_* |
|
38 | - * @psalm-param IQueryBuilder::PARAM_* $type |
|
39 | - * @return IQueryFunction |
|
40 | - */ |
|
41 | - public function castColumn($column, $type): IQueryFunction { |
|
42 | - switch ($type) { |
|
43 | - case IQueryBuilder::PARAM_INT: |
|
44 | - return new QueryFunction('CAST(' . $this->helper->quoteColumnName($column) . ' AS INT)'); |
|
45 | - case IQueryBuilder::PARAM_STR: |
|
46 | - return new QueryFunction('CAST(' . $this->helper->quoteColumnName($column) . ' AS TEXT)'); |
|
47 | - default: |
|
48 | - return parent::castColumn($column, $type); |
|
49 | - } |
|
50 | - } |
|
33 | + /** |
|
34 | + * Returns a IQueryFunction that casts the column to the given type |
|
35 | + * |
|
36 | + * @param string|IQueryFunction $column |
|
37 | + * @param mixed $type One of IQueryBuilder::PARAM_* |
|
38 | + * @psalm-param IQueryBuilder::PARAM_* $type |
|
39 | + * @return IQueryFunction |
|
40 | + */ |
|
41 | + public function castColumn($column, $type): IQueryFunction { |
|
42 | + switch ($type) { |
|
43 | + case IQueryBuilder::PARAM_INT: |
|
44 | + return new QueryFunction('CAST(' . $this->helper->quoteColumnName($column) . ' AS INT)'); |
|
45 | + case IQueryBuilder::PARAM_STR: |
|
46 | + return new QueryFunction('CAST(' . $this->helper->quoteColumnName($column) . ' AS TEXT)'); |
|
47 | + default: |
|
48 | + return parent::castColumn($column, $type); |
|
49 | + } |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * @inheritdoc |
|
54 | - */ |
|
55 | - public function iLike($x, $y, $type = null): string { |
|
56 | - $x = $this->helper->quoteColumnName($x); |
|
57 | - $y = $this->helper->quoteColumnName($y); |
|
58 | - return $this->expressionBuilder->comparison($x, 'ILIKE', $y); |
|
59 | - } |
|
52 | + /** |
|
53 | + * @inheritdoc |
|
54 | + */ |
|
55 | + public function iLike($x, $y, $type = null): string { |
|
56 | + $x = $this->helper->quoteColumnName($x); |
|
57 | + $y = $this->helper->quoteColumnName($y); |
|
58 | + return $this->expressionBuilder->comparison($x, 'ILIKE', $y); |
|
59 | + } |
|
60 | 60 | } |
@@ -32,164 +32,164 @@ |
||
32 | 32 | |
33 | 33 | class OCIExpressionBuilder extends ExpressionBuilder { |
34 | 34 | |
35 | - /** |
|
36 | - * @param mixed $column |
|
37 | - * @param mixed|null $type |
|
38 | - * @return array|IQueryFunction|string |
|
39 | - */ |
|
40 | - protected function prepareColumn($column, $type) { |
|
41 | - if ($type === IQueryBuilder::PARAM_STR && !is_array($column) && !($column instanceof IParameter) && !($column instanceof ILiteral)) { |
|
42 | - $column = $this->castColumn($column, $type); |
|
43 | - } else { |
|
44 | - $column = $this->helper->quoteColumnNames($column); |
|
45 | - } |
|
46 | - return $column; |
|
47 | - } |
|
48 | - |
|
49 | - /** |
|
50 | - * @inheritdoc |
|
51 | - */ |
|
52 | - public function comparison($x, string $operator, $y, $type = null): string { |
|
53 | - $x = $this->prepareColumn($x, $type); |
|
54 | - $y = $this->prepareColumn($y, $type); |
|
55 | - |
|
56 | - return $this->expressionBuilder->comparison($x, $operator, $y); |
|
57 | - } |
|
58 | - |
|
59 | - /** |
|
60 | - * @inheritdoc |
|
61 | - */ |
|
62 | - public function eq($x, $y, $type = null): string { |
|
63 | - $x = $this->prepareColumn($x, $type); |
|
64 | - $y = $this->prepareColumn($y, $type); |
|
65 | - |
|
66 | - return $this->expressionBuilder->eq($x, $y); |
|
67 | - } |
|
68 | - |
|
69 | - /** |
|
70 | - * @inheritdoc |
|
71 | - */ |
|
72 | - public function neq($x, $y, $type = null): string { |
|
73 | - $x = $this->prepareColumn($x, $type); |
|
74 | - $y = $this->prepareColumn($y, $type); |
|
75 | - |
|
76 | - return $this->expressionBuilder->neq($x, $y); |
|
77 | - } |
|
78 | - |
|
79 | - /** |
|
80 | - * @inheritdoc |
|
81 | - */ |
|
82 | - public function lt($x, $y, $type = null): string { |
|
83 | - $x = $this->prepareColumn($x, $type); |
|
84 | - $y = $this->prepareColumn($y, $type); |
|
85 | - |
|
86 | - return $this->expressionBuilder->lt($x, $y); |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * @inheritdoc |
|
91 | - */ |
|
92 | - public function lte($x, $y, $type = null): string { |
|
93 | - $x = $this->prepareColumn($x, $type); |
|
94 | - $y = $this->prepareColumn($y, $type); |
|
95 | - |
|
96 | - return $this->expressionBuilder->lte($x, $y); |
|
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * @inheritdoc |
|
101 | - */ |
|
102 | - public function gt($x, $y, $type = null): string { |
|
103 | - $x = $this->prepareColumn($x, $type); |
|
104 | - $y = $this->prepareColumn($y, $type); |
|
105 | - |
|
106 | - return $this->expressionBuilder->gt($x, $y); |
|
107 | - } |
|
108 | - |
|
109 | - /** |
|
110 | - * @inheritdoc |
|
111 | - */ |
|
112 | - public function gte($x, $y, $type = null): string { |
|
113 | - $x = $this->prepareColumn($x, $type); |
|
114 | - $y = $this->prepareColumn($y, $type); |
|
115 | - |
|
116 | - return $this->expressionBuilder->gte($x, $y); |
|
117 | - } |
|
118 | - |
|
119 | - /** |
|
120 | - * @inheritdoc |
|
121 | - */ |
|
122 | - public function in($x, $y, $type = null): string { |
|
123 | - $x = $this->prepareColumn($x, $type); |
|
124 | - $y = $this->prepareColumn($y, $type); |
|
125 | - |
|
126 | - return $this->expressionBuilder->in($x, $y); |
|
127 | - } |
|
128 | - |
|
129 | - /** |
|
130 | - * @inheritdoc |
|
131 | - */ |
|
132 | - public function notIn($x, $y, $type = null): string { |
|
133 | - $x = $this->prepareColumn($x, $type); |
|
134 | - $y = $this->prepareColumn($y, $type); |
|
135 | - |
|
136 | - return $this->expressionBuilder->notIn($x, $y); |
|
137 | - } |
|
138 | - |
|
139 | - /** |
|
140 | - * Creates a $x = '' statement, because Oracle needs a different check |
|
141 | - * |
|
142 | - * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be inspected by the comparison. |
|
143 | - * @return string |
|
144 | - * @since 13.0.0 |
|
145 | - */ |
|
146 | - public function emptyString($x): string { |
|
147 | - return $this->isNull($x); |
|
148 | - } |
|
149 | - |
|
150 | - /** |
|
151 | - * Creates a `$x <> ''` statement, because Oracle needs a different check |
|
152 | - * |
|
153 | - * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be inspected by the comparison. |
|
154 | - * @return string |
|
155 | - * @since 13.0.0 |
|
156 | - */ |
|
157 | - public function nonEmptyString($x): string { |
|
158 | - return $this->isNotNull($x); |
|
159 | - } |
|
160 | - |
|
161 | - /** |
|
162 | - * Returns a IQueryFunction that casts the column to the given type |
|
163 | - * |
|
164 | - * @param string|IQueryFunction $column |
|
165 | - * @param mixed $type One of IQueryBuilder::PARAM_* |
|
166 | - * @psalm-param IQueryBuilder::PARAM_* $type |
|
167 | - * @return IQueryFunction |
|
168 | - */ |
|
169 | - public function castColumn($column, $type): IQueryFunction { |
|
170 | - if ($type === IQueryBuilder::PARAM_STR) { |
|
171 | - $column = $this->helper->quoteColumnName($column); |
|
172 | - return new QueryFunction('to_char(' . $column . ')'); |
|
173 | - } |
|
174 | - if ($type === IQueryBuilder::PARAM_INT) { |
|
175 | - $column = $this->helper->quoteColumnName($column); |
|
176 | - return new QueryFunction('to_number(to_char(' . $column . '))'); |
|
177 | - } |
|
178 | - |
|
179 | - return parent::castColumn($column, $type); |
|
180 | - } |
|
181 | - |
|
182 | - /** |
|
183 | - * @inheritdoc |
|
184 | - */ |
|
185 | - public function like($x, $y, $type = null): string { |
|
186 | - return parent::like($x, $y, $type) . " ESCAPE '\\'"; |
|
187 | - } |
|
188 | - |
|
189 | - /** |
|
190 | - * @inheritdoc |
|
191 | - */ |
|
192 | - public function iLike($x, $y, $type = null): string { |
|
193 | - return $this->like($this->functionBuilder->lower($x), $this->functionBuilder->lower($y)); |
|
194 | - } |
|
35 | + /** |
|
36 | + * @param mixed $column |
|
37 | + * @param mixed|null $type |
|
38 | + * @return array|IQueryFunction|string |
|
39 | + */ |
|
40 | + protected function prepareColumn($column, $type) { |
|
41 | + if ($type === IQueryBuilder::PARAM_STR && !is_array($column) && !($column instanceof IParameter) && !($column instanceof ILiteral)) { |
|
42 | + $column = $this->castColumn($column, $type); |
|
43 | + } else { |
|
44 | + $column = $this->helper->quoteColumnNames($column); |
|
45 | + } |
|
46 | + return $column; |
|
47 | + } |
|
48 | + |
|
49 | + /** |
|
50 | + * @inheritdoc |
|
51 | + */ |
|
52 | + public function comparison($x, string $operator, $y, $type = null): string { |
|
53 | + $x = $this->prepareColumn($x, $type); |
|
54 | + $y = $this->prepareColumn($y, $type); |
|
55 | + |
|
56 | + return $this->expressionBuilder->comparison($x, $operator, $y); |
|
57 | + } |
|
58 | + |
|
59 | + /** |
|
60 | + * @inheritdoc |
|
61 | + */ |
|
62 | + public function eq($x, $y, $type = null): string { |
|
63 | + $x = $this->prepareColumn($x, $type); |
|
64 | + $y = $this->prepareColumn($y, $type); |
|
65 | + |
|
66 | + return $this->expressionBuilder->eq($x, $y); |
|
67 | + } |
|
68 | + |
|
69 | + /** |
|
70 | + * @inheritdoc |
|
71 | + */ |
|
72 | + public function neq($x, $y, $type = null): string { |
|
73 | + $x = $this->prepareColumn($x, $type); |
|
74 | + $y = $this->prepareColumn($y, $type); |
|
75 | + |
|
76 | + return $this->expressionBuilder->neq($x, $y); |
|
77 | + } |
|
78 | + |
|
79 | + /** |
|
80 | + * @inheritdoc |
|
81 | + */ |
|
82 | + public function lt($x, $y, $type = null): string { |
|
83 | + $x = $this->prepareColumn($x, $type); |
|
84 | + $y = $this->prepareColumn($y, $type); |
|
85 | + |
|
86 | + return $this->expressionBuilder->lt($x, $y); |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * @inheritdoc |
|
91 | + */ |
|
92 | + public function lte($x, $y, $type = null): string { |
|
93 | + $x = $this->prepareColumn($x, $type); |
|
94 | + $y = $this->prepareColumn($y, $type); |
|
95 | + |
|
96 | + return $this->expressionBuilder->lte($x, $y); |
|
97 | + } |
|
98 | + |
|
99 | + /** |
|
100 | + * @inheritdoc |
|
101 | + */ |
|
102 | + public function gt($x, $y, $type = null): string { |
|
103 | + $x = $this->prepareColumn($x, $type); |
|
104 | + $y = $this->prepareColumn($y, $type); |
|
105 | + |
|
106 | + return $this->expressionBuilder->gt($x, $y); |
|
107 | + } |
|
108 | + |
|
109 | + /** |
|
110 | + * @inheritdoc |
|
111 | + */ |
|
112 | + public function gte($x, $y, $type = null): string { |
|
113 | + $x = $this->prepareColumn($x, $type); |
|
114 | + $y = $this->prepareColumn($y, $type); |
|
115 | + |
|
116 | + return $this->expressionBuilder->gte($x, $y); |
|
117 | + } |
|
118 | + |
|
119 | + /** |
|
120 | + * @inheritdoc |
|
121 | + */ |
|
122 | + public function in($x, $y, $type = null): string { |
|
123 | + $x = $this->prepareColumn($x, $type); |
|
124 | + $y = $this->prepareColumn($y, $type); |
|
125 | + |
|
126 | + return $this->expressionBuilder->in($x, $y); |
|
127 | + } |
|
128 | + |
|
129 | + /** |
|
130 | + * @inheritdoc |
|
131 | + */ |
|
132 | + public function notIn($x, $y, $type = null): string { |
|
133 | + $x = $this->prepareColumn($x, $type); |
|
134 | + $y = $this->prepareColumn($y, $type); |
|
135 | + |
|
136 | + return $this->expressionBuilder->notIn($x, $y); |
|
137 | + } |
|
138 | + |
|
139 | + /** |
|
140 | + * Creates a $x = '' statement, because Oracle needs a different check |
|
141 | + * |
|
142 | + * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be inspected by the comparison. |
|
143 | + * @return string |
|
144 | + * @since 13.0.0 |
|
145 | + */ |
|
146 | + public function emptyString($x): string { |
|
147 | + return $this->isNull($x); |
|
148 | + } |
|
149 | + |
|
150 | + /** |
|
151 | + * Creates a `$x <> ''` statement, because Oracle needs a different check |
|
152 | + * |
|
153 | + * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be inspected by the comparison. |
|
154 | + * @return string |
|
155 | + * @since 13.0.0 |
|
156 | + */ |
|
157 | + public function nonEmptyString($x): string { |
|
158 | + return $this->isNotNull($x); |
|
159 | + } |
|
160 | + |
|
161 | + /** |
|
162 | + * Returns a IQueryFunction that casts the column to the given type |
|
163 | + * |
|
164 | + * @param string|IQueryFunction $column |
|
165 | + * @param mixed $type One of IQueryBuilder::PARAM_* |
|
166 | + * @psalm-param IQueryBuilder::PARAM_* $type |
|
167 | + * @return IQueryFunction |
|
168 | + */ |
|
169 | + public function castColumn($column, $type): IQueryFunction { |
|
170 | + if ($type === IQueryBuilder::PARAM_STR) { |
|
171 | + $column = $this->helper->quoteColumnName($column); |
|
172 | + return new QueryFunction('to_char(' . $column . ')'); |
|
173 | + } |
|
174 | + if ($type === IQueryBuilder::PARAM_INT) { |
|
175 | + $column = $this->helper->quoteColumnName($column); |
|
176 | + return new QueryFunction('to_number(to_char(' . $column . '))'); |
|
177 | + } |
|
178 | + |
|
179 | + return parent::castColumn($column, $type); |
|
180 | + } |
|
181 | + |
|
182 | + /** |
|
183 | + * @inheritdoc |
|
184 | + */ |
|
185 | + public function like($x, $y, $type = null): string { |
|
186 | + return parent::like($x, $y, $type) . " ESCAPE '\\'"; |
|
187 | + } |
|
188 | + |
|
189 | + /** |
|
190 | + * @inheritdoc |
|
191 | + */ |
|
192 | + public function iLike($x, $y, $type = null): string { |
|
193 | + return $this->like($this->functionBuilder->lower($x), $this->functionBuilder->lower($y)); |
|
194 | + } |
|
195 | 195 | } |
@@ -42,397 +42,397 @@ |
||
42 | 42 | use OCP\IDBConnection; |
43 | 43 | |
44 | 44 | class ExpressionBuilder implements IExpressionBuilder { |
45 | - /** @var \Doctrine\DBAL\Query\Expression\ExpressionBuilder */ |
|
46 | - protected $expressionBuilder; |
|
45 | + /** @var \Doctrine\DBAL\Query\Expression\ExpressionBuilder */ |
|
46 | + protected $expressionBuilder; |
|
47 | 47 | |
48 | - /** @var QuoteHelper */ |
|
49 | - protected $helper; |
|
48 | + /** @var QuoteHelper */ |
|
49 | + protected $helper; |
|
50 | 50 | |
51 | - /** @var IDBConnection */ |
|
52 | - protected $connection; |
|
51 | + /** @var IDBConnection */ |
|
52 | + protected $connection; |
|
53 | 53 | |
54 | - /** @var FunctionBuilder */ |
|
55 | - protected $functionBuilder; |
|
54 | + /** @var FunctionBuilder */ |
|
55 | + protected $functionBuilder; |
|
56 | 56 | |
57 | - /** |
|
58 | - * Initializes a new <tt>ExpressionBuilder</tt>. |
|
59 | - * |
|
60 | - * @param ConnectionAdapter $connection |
|
61 | - * @param IQueryBuilder $queryBuilder |
|
62 | - */ |
|
63 | - public function __construct(ConnectionAdapter $connection, IQueryBuilder $queryBuilder) { |
|
64 | - $this->connection = $connection; |
|
65 | - $this->helper = new QuoteHelper(); |
|
66 | - $this->expressionBuilder = new DoctrineExpressionBuilder($connection->getInner()); |
|
67 | - $this->functionBuilder = $queryBuilder->func(); |
|
68 | - } |
|
57 | + /** |
|
58 | + * Initializes a new <tt>ExpressionBuilder</tt>. |
|
59 | + * |
|
60 | + * @param ConnectionAdapter $connection |
|
61 | + * @param IQueryBuilder $queryBuilder |
|
62 | + */ |
|
63 | + public function __construct(ConnectionAdapter $connection, IQueryBuilder $queryBuilder) { |
|
64 | + $this->connection = $connection; |
|
65 | + $this->helper = new QuoteHelper(); |
|
66 | + $this->expressionBuilder = new DoctrineExpressionBuilder($connection->getInner()); |
|
67 | + $this->functionBuilder = $queryBuilder->func(); |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * Creates a conjunction of the given boolean expressions. |
|
72 | - * |
|
73 | - * Example: |
|
74 | - * |
|
75 | - * [php] |
|
76 | - * // (u.type = ?) AND (u.role = ?) |
|
77 | - * $expr->andX('u.type = ?', 'u.role = ?')); |
|
78 | - * |
|
79 | - * @param mixed ...$x Optional clause. Defaults = null, but requires |
|
80 | - * at least one defined when converting to string. |
|
81 | - * |
|
82 | - * @return \OCP\DB\QueryBuilder\ICompositeExpression |
|
83 | - */ |
|
84 | - public function andX(...$x): ICompositeExpression { |
|
85 | - $compositeExpression = call_user_func_array([$this->expressionBuilder, 'andX'], $x); |
|
86 | - return new CompositeExpression($compositeExpression); |
|
87 | - } |
|
70 | + /** |
|
71 | + * Creates a conjunction of the given boolean expressions. |
|
72 | + * |
|
73 | + * Example: |
|
74 | + * |
|
75 | + * [php] |
|
76 | + * // (u.type = ?) AND (u.role = ?) |
|
77 | + * $expr->andX('u.type = ?', 'u.role = ?')); |
|
78 | + * |
|
79 | + * @param mixed ...$x Optional clause. Defaults = null, but requires |
|
80 | + * at least one defined when converting to string. |
|
81 | + * |
|
82 | + * @return \OCP\DB\QueryBuilder\ICompositeExpression |
|
83 | + */ |
|
84 | + public function andX(...$x): ICompositeExpression { |
|
85 | + $compositeExpression = call_user_func_array([$this->expressionBuilder, 'andX'], $x); |
|
86 | + return new CompositeExpression($compositeExpression); |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * Creates a disjunction of the given boolean expressions. |
|
91 | - * |
|
92 | - * Example: |
|
93 | - * |
|
94 | - * [php] |
|
95 | - * // (u.type = ?) OR (u.role = ?) |
|
96 | - * $qb->where($qb->expr()->orX('u.type = ?', 'u.role = ?')); |
|
97 | - * |
|
98 | - * @param mixed ...$x Optional clause. Defaults = null, but requires |
|
99 | - * at least one defined when converting to string. |
|
100 | - * |
|
101 | - * @return \OCP\DB\QueryBuilder\ICompositeExpression |
|
102 | - */ |
|
103 | - public function orX(...$x): ICompositeExpression { |
|
104 | - $compositeExpression = call_user_func_array([$this->expressionBuilder, 'orX'], $x); |
|
105 | - return new CompositeExpression($compositeExpression); |
|
106 | - } |
|
89 | + /** |
|
90 | + * Creates a disjunction of the given boolean expressions. |
|
91 | + * |
|
92 | + * Example: |
|
93 | + * |
|
94 | + * [php] |
|
95 | + * // (u.type = ?) OR (u.role = ?) |
|
96 | + * $qb->where($qb->expr()->orX('u.type = ?', 'u.role = ?')); |
|
97 | + * |
|
98 | + * @param mixed ...$x Optional clause. Defaults = null, but requires |
|
99 | + * at least one defined when converting to string. |
|
100 | + * |
|
101 | + * @return \OCP\DB\QueryBuilder\ICompositeExpression |
|
102 | + */ |
|
103 | + public function orX(...$x): ICompositeExpression { |
|
104 | + $compositeExpression = call_user_func_array([$this->expressionBuilder, 'orX'], $x); |
|
105 | + return new CompositeExpression($compositeExpression); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * Creates a comparison expression. |
|
110 | - * |
|
111 | - * @param mixed $x The left expression. |
|
112 | - * @param string $operator One of the IExpressionBuilder::* constants. |
|
113 | - * @param mixed $y The right expression. |
|
114 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
115 | - * required when comparing text fields for oci compatibility |
|
116 | - * |
|
117 | - * @return string |
|
118 | - */ |
|
119 | - public function comparison($x, string $operator, $y, $type = null): string { |
|
120 | - $x = $this->helper->quoteColumnName($x); |
|
121 | - $y = $this->helper->quoteColumnName($y); |
|
122 | - return $this->expressionBuilder->comparison($x, $operator, $y); |
|
123 | - } |
|
108 | + /** |
|
109 | + * Creates a comparison expression. |
|
110 | + * |
|
111 | + * @param mixed $x The left expression. |
|
112 | + * @param string $operator One of the IExpressionBuilder::* constants. |
|
113 | + * @param mixed $y The right expression. |
|
114 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
115 | + * required when comparing text fields for oci compatibility |
|
116 | + * |
|
117 | + * @return string |
|
118 | + */ |
|
119 | + public function comparison($x, string $operator, $y, $type = null): string { |
|
120 | + $x = $this->helper->quoteColumnName($x); |
|
121 | + $y = $this->helper->quoteColumnName($y); |
|
122 | + return $this->expressionBuilder->comparison($x, $operator, $y); |
|
123 | + } |
|
124 | 124 | |
125 | - /** |
|
126 | - * Creates an equality comparison expression with the given arguments. |
|
127 | - * |
|
128 | - * First argument is considered the left expression and the second is the right expression. |
|
129 | - * When converted to string, it will generated a <left expr> = <right expr>. Example: |
|
130 | - * |
|
131 | - * [php] |
|
132 | - * // u.id = ? |
|
133 | - * $expr->eq('u.id', '?'); |
|
134 | - * |
|
135 | - * @param mixed $x The left expression. |
|
136 | - * @param mixed $y The right expression. |
|
137 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
138 | - * required when comparing text fields for oci compatibility |
|
139 | - * |
|
140 | - * @return string |
|
141 | - */ |
|
142 | - public function eq($x, $y, $type = null): string { |
|
143 | - $x = $this->helper->quoteColumnName($x); |
|
144 | - $y = $this->helper->quoteColumnName($y); |
|
145 | - return $this->expressionBuilder->eq($x, $y); |
|
146 | - } |
|
125 | + /** |
|
126 | + * Creates an equality comparison expression with the given arguments. |
|
127 | + * |
|
128 | + * First argument is considered the left expression and the second is the right expression. |
|
129 | + * When converted to string, it will generated a <left expr> = <right expr>. Example: |
|
130 | + * |
|
131 | + * [php] |
|
132 | + * // u.id = ? |
|
133 | + * $expr->eq('u.id', '?'); |
|
134 | + * |
|
135 | + * @param mixed $x The left expression. |
|
136 | + * @param mixed $y The right expression. |
|
137 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
138 | + * required when comparing text fields for oci compatibility |
|
139 | + * |
|
140 | + * @return string |
|
141 | + */ |
|
142 | + public function eq($x, $y, $type = null): string { |
|
143 | + $x = $this->helper->quoteColumnName($x); |
|
144 | + $y = $this->helper->quoteColumnName($y); |
|
145 | + return $this->expressionBuilder->eq($x, $y); |
|
146 | + } |
|
147 | 147 | |
148 | - /** |
|
149 | - * Creates a non equality comparison expression with the given arguments. |
|
150 | - * First argument is considered the left expression and the second is the right expression. |
|
151 | - * When converted to string, it will generated a <left expr> <> <right expr>. Example: |
|
152 | - * |
|
153 | - * [php] |
|
154 | - * // u.id <> 1 |
|
155 | - * $q->where($q->expr()->neq('u.id', '1')); |
|
156 | - * |
|
157 | - * @param mixed $x The left expression. |
|
158 | - * @param mixed $y The right expression. |
|
159 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
160 | - * required when comparing text fields for oci compatibility |
|
161 | - * |
|
162 | - * @return string |
|
163 | - */ |
|
164 | - public function neq($x, $y, $type = null): string { |
|
165 | - $x = $this->helper->quoteColumnName($x); |
|
166 | - $y = $this->helper->quoteColumnName($y); |
|
167 | - return $this->expressionBuilder->neq($x, $y); |
|
168 | - } |
|
148 | + /** |
|
149 | + * Creates a non equality comparison expression with the given arguments. |
|
150 | + * First argument is considered the left expression and the second is the right expression. |
|
151 | + * When converted to string, it will generated a <left expr> <> <right expr>. Example: |
|
152 | + * |
|
153 | + * [php] |
|
154 | + * // u.id <> 1 |
|
155 | + * $q->where($q->expr()->neq('u.id', '1')); |
|
156 | + * |
|
157 | + * @param mixed $x The left expression. |
|
158 | + * @param mixed $y The right expression. |
|
159 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
160 | + * required when comparing text fields for oci compatibility |
|
161 | + * |
|
162 | + * @return string |
|
163 | + */ |
|
164 | + public function neq($x, $y, $type = null): string { |
|
165 | + $x = $this->helper->quoteColumnName($x); |
|
166 | + $y = $this->helper->quoteColumnName($y); |
|
167 | + return $this->expressionBuilder->neq($x, $y); |
|
168 | + } |
|
169 | 169 | |
170 | - /** |
|
171 | - * Creates a lower-than comparison expression with the given arguments. |
|
172 | - * First argument is considered the left expression and the second is the right expression. |
|
173 | - * When converted to string, it will generated a <left expr> < <right expr>. Example: |
|
174 | - * |
|
175 | - * [php] |
|
176 | - * // u.id < ? |
|
177 | - * $q->where($q->expr()->lt('u.id', '?')); |
|
178 | - * |
|
179 | - * @param mixed $x The left expression. |
|
180 | - * @param mixed $y The right expression. |
|
181 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
182 | - * required when comparing text fields for oci compatibility |
|
183 | - * |
|
184 | - * @return string |
|
185 | - */ |
|
186 | - public function lt($x, $y, $type = null): string { |
|
187 | - $x = $this->helper->quoteColumnName($x); |
|
188 | - $y = $this->helper->quoteColumnName($y); |
|
189 | - return $this->expressionBuilder->lt($x, $y); |
|
190 | - } |
|
170 | + /** |
|
171 | + * Creates a lower-than comparison expression with the given arguments. |
|
172 | + * First argument is considered the left expression and the second is the right expression. |
|
173 | + * When converted to string, it will generated a <left expr> < <right expr>. Example: |
|
174 | + * |
|
175 | + * [php] |
|
176 | + * // u.id < ? |
|
177 | + * $q->where($q->expr()->lt('u.id', '?')); |
|
178 | + * |
|
179 | + * @param mixed $x The left expression. |
|
180 | + * @param mixed $y The right expression. |
|
181 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
182 | + * required when comparing text fields for oci compatibility |
|
183 | + * |
|
184 | + * @return string |
|
185 | + */ |
|
186 | + public function lt($x, $y, $type = null): string { |
|
187 | + $x = $this->helper->quoteColumnName($x); |
|
188 | + $y = $this->helper->quoteColumnName($y); |
|
189 | + return $this->expressionBuilder->lt($x, $y); |
|
190 | + } |
|
191 | 191 | |
192 | - /** |
|
193 | - * Creates a lower-than-equal comparison expression with the given arguments. |
|
194 | - * First argument is considered the left expression and the second is the right expression. |
|
195 | - * When converted to string, it will generated a <left expr> <= <right expr>. Example: |
|
196 | - * |
|
197 | - * [php] |
|
198 | - * // u.id <= ? |
|
199 | - * $q->where($q->expr()->lte('u.id', '?')); |
|
200 | - * |
|
201 | - * @param mixed $x The left expression. |
|
202 | - * @param mixed $y The right expression. |
|
203 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
204 | - * required when comparing text fields for oci compatibility |
|
205 | - * |
|
206 | - * @return string |
|
207 | - */ |
|
208 | - public function lte($x, $y, $type = null): string { |
|
209 | - $x = $this->helper->quoteColumnName($x); |
|
210 | - $y = $this->helper->quoteColumnName($y); |
|
211 | - return $this->expressionBuilder->lte($x, $y); |
|
212 | - } |
|
192 | + /** |
|
193 | + * Creates a lower-than-equal comparison expression with the given arguments. |
|
194 | + * First argument is considered the left expression and the second is the right expression. |
|
195 | + * When converted to string, it will generated a <left expr> <= <right expr>. Example: |
|
196 | + * |
|
197 | + * [php] |
|
198 | + * // u.id <= ? |
|
199 | + * $q->where($q->expr()->lte('u.id', '?')); |
|
200 | + * |
|
201 | + * @param mixed $x The left expression. |
|
202 | + * @param mixed $y The right expression. |
|
203 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
204 | + * required when comparing text fields for oci compatibility |
|
205 | + * |
|
206 | + * @return string |
|
207 | + */ |
|
208 | + public function lte($x, $y, $type = null): string { |
|
209 | + $x = $this->helper->quoteColumnName($x); |
|
210 | + $y = $this->helper->quoteColumnName($y); |
|
211 | + return $this->expressionBuilder->lte($x, $y); |
|
212 | + } |
|
213 | 213 | |
214 | - /** |
|
215 | - * Creates a greater-than comparison expression with the given arguments. |
|
216 | - * First argument is considered the left expression and the second is the right expression. |
|
217 | - * When converted to string, it will generated a <left expr> > <right expr>. Example: |
|
218 | - * |
|
219 | - * [php] |
|
220 | - * // u.id > ? |
|
221 | - * $q->where($q->expr()->gt('u.id', '?')); |
|
222 | - * |
|
223 | - * @param mixed $x The left expression. |
|
224 | - * @param mixed $y The right expression. |
|
225 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
226 | - * required when comparing text fields for oci compatibility |
|
227 | - * |
|
228 | - * @return string |
|
229 | - */ |
|
230 | - public function gt($x, $y, $type = null): string { |
|
231 | - $x = $this->helper->quoteColumnName($x); |
|
232 | - $y = $this->helper->quoteColumnName($y); |
|
233 | - return $this->expressionBuilder->gt($x, $y); |
|
234 | - } |
|
214 | + /** |
|
215 | + * Creates a greater-than comparison expression with the given arguments. |
|
216 | + * First argument is considered the left expression and the second is the right expression. |
|
217 | + * When converted to string, it will generated a <left expr> > <right expr>. Example: |
|
218 | + * |
|
219 | + * [php] |
|
220 | + * // u.id > ? |
|
221 | + * $q->where($q->expr()->gt('u.id', '?')); |
|
222 | + * |
|
223 | + * @param mixed $x The left expression. |
|
224 | + * @param mixed $y The right expression. |
|
225 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
226 | + * required when comparing text fields for oci compatibility |
|
227 | + * |
|
228 | + * @return string |
|
229 | + */ |
|
230 | + public function gt($x, $y, $type = null): string { |
|
231 | + $x = $this->helper->quoteColumnName($x); |
|
232 | + $y = $this->helper->quoteColumnName($y); |
|
233 | + return $this->expressionBuilder->gt($x, $y); |
|
234 | + } |
|
235 | 235 | |
236 | - /** |
|
237 | - * Creates a greater-than-equal comparison expression with the given arguments. |
|
238 | - * First argument is considered the left expression and the second is the right expression. |
|
239 | - * When converted to string, it will generated a <left expr> >= <right expr>. Example: |
|
240 | - * |
|
241 | - * [php] |
|
242 | - * // u.id >= ? |
|
243 | - * $q->where($q->expr()->gte('u.id', '?')); |
|
244 | - * |
|
245 | - * @param mixed $x The left expression. |
|
246 | - * @param mixed $y The right expression. |
|
247 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
248 | - * required when comparing text fields for oci compatibility |
|
249 | - * |
|
250 | - * @return string |
|
251 | - */ |
|
252 | - public function gte($x, $y, $type = null): string { |
|
253 | - $x = $this->helper->quoteColumnName($x); |
|
254 | - $y = $this->helper->quoteColumnName($y); |
|
255 | - return $this->expressionBuilder->gte($x, $y); |
|
256 | - } |
|
236 | + /** |
|
237 | + * Creates a greater-than-equal comparison expression with the given arguments. |
|
238 | + * First argument is considered the left expression and the second is the right expression. |
|
239 | + * When converted to string, it will generated a <left expr> >= <right expr>. Example: |
|
240 | + * |
|
241 | + * [php] |
|
242 | + * // u.id >= ? |
|
243 | + * $q->where($q->expr()->gte('u.id', '?')); |
|
244 | + * |
|
245 | + * @param mixed $x The left expression. |
|
246 | + * @param mixed $y The right expression. |
|
247 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
248 | + * required when comparing text fields for oci compatibility |
|
249 | + * |
|
250 | + * @return string |
|
251 | + */ |
|
252 | + public function gte($x, $y, $type = null): string { |
|
253 | + $x = $this->helper->quoteColumnName($x); |
|
254 | + $y = $this->helper->quoteColumnName($y); |
|
255 | + return $this->expressionBuilder->gte($x, $y); |
|
256 | + } |
|
257 | 257 | |
258 | - /** |
|
259 | - * Creates an IS NULL expression with the given arguments. |
|
260 | - * |
|
261 | - * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be restricted by IS NULL. |
|
262 | - * |
|
263 | - * @return string |
|
264 | - */ |
|
265 | - public function isNull($x): string { |
|
266 | - $x = $this->helper->quoteColumnName($x); |
|
267 | - return $this->expressionBuilder->isNull($x); |
|
268 | - } |
|
258 | + /** |
|
259 | + * Creates an IS NULL expression with the given arguments. |
|
260 | + * |
|
261 | + * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be restricted by IS NULL. |
|
262 | + * |
|
263 | + * @return string |
|
264 | + */ |
|
265 | + public function isNull($x): string { |
|
266 | + $x = $this->helper->quoteColumnName($x); |
|
267 | + return $this->expressionBuilder->isNull($x); |
|
268 | + } |
|
269 | 269 | |
270 | - /** |
|
271 | - * Creates an IS NOT NULL expression with the given arguments. |
|
272 | - * |
|
273 | - * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be restricted by IS NOT NULL. |
|
274 | - * |
|
275 | - * @return string |
|
276 | - */ |
|
277 | - public function isNotNull($x): string { |
|
278 | - $x = $this->helper->quoteColumnName($x); |
|
279 | - return $this->expressionBuilder->isNotNull($x); |
|
280 | - } |
|
270 | + /** |
|
271 | + * Creates an IS NOT NULL expression with the given arguments. |
|
272 | + * |
|
273 | + * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be restricted by IS NOT NULL. |
|
274 | + * |
|
275 | + * @return string |
|
276 | + */ |
|
277 | + public function isNotNull($x): string { |
|
278 | + $x = $this->helper->quoteColumnName($x); |
|
279 | + return $this->expressionBuilder->isNotNull($x); |
|
280 | + } |
|
281 | 281 | |
282 | - /** |
|
283 | - * Creates a LIKE() comparison expression with the given arguments. |
|
284 | - * |
|
285 | - * @param ILiteral|IParameter|IQueryFunction|string $x Field in string format to be inspected by LIKE() comparison. |
|
286 | - * @param mixed $y Argument to be used in LIKE() comparison. |
|
287 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
288 | - * required when comparing text fields for oci compatibility |
|
289 | - * |
|
290 | - * @return string |
|
291 | - */ |
|
292 | - public function like($x, $y, $type = null): string { |
|
293 | - $x = $this->helper->quoteColumnName($x); |
|
294 | - $y = $this->helper->quoteColumnName($y); |
|
295 | - return $this->expressionBuilder->like($x, $y); |
|
296 | - } |
|
282 | + /** |
|
283 | + * Creates a LIKE() comparison expression with the given arguments. |
|
284 | + * |
|
285 | + * @param ILiteral|IParameter|IQueryFunction|string $x Field in string format to be inspected by LIKE() comparison. |
|
286 | + * @param mixed $y Argument to be used in LIKE() comparison. |
|
287 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
288 | + * required when comparing text fields for oci compatibility |
|
289 | + * |
|
290 | + * @return string |
|
291 | + */ |
|
292 | + public function like($x, $y, $type = null): string { |
|
293 | + $x = $this->helper->quoteColumnName($x); |
|
294 | + $y = $this->helper->quoteColumnName($y); |
|
295 | + return $this->expressionBuilder->like($x, $y); |
|
296 | + } |
|
297 | 297 | |
298 | - /** |
|
299 | - * Creates a ILIKE() comparison expression with the given arguments. |
|
300 | - * |
|
301 | - * @param string $x Field in string format to be inspected by ILIKE() comparison. |
|
302 | - * @param mixed $y Argument to be used in ILIKE() comparison. |
|
303 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
304 | - * required when comparing text fields for oci compatibility |
|
305 | - * |
|
306 | - * @return string |
|
307 | - * @since 9.0.0 |
|
308 | - */ |
|
309 | - public function iLike($x, $y, $type = null): string { |
|
310 | - return $this->expressionBuilder->like($this->functionBuilder->lower($x), $this->functionBuilder->lower($y)); |
|
311 | - } |
|
298 | + /** |
|
299 | + * Creates a ILIKE() comparison expression with the given arguments. |
|
300 | + * |
|
301 | + * @param string $x Field in string format to be inspected by ILIKE() comparison. |
|
302 | + * @param mixed $y Argument to be used in ILIKE() comparison. |
|
303 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
304 | + * required when comparing text fields for oci compatibility |
|
305 | + * |
|
306 | + * @return string |
|
307 | + * @since 9.0.0 |
|
308 | + */ |
|
309 | + public function iLike($x, $y, $type = null): string { |
|
310 | + return $this->expressionBuilder->like($this->functionBuilder->lower($x), $this->functionBuilder->lower($y)); |
|
311 | + } |
|
312 | 312 | |
313 | - /** |
|
314 | - * Creates a NOT LIKE() comparison expression with the given arguments. |
|
315 | - * |
|
316 | - * @param ILiteral|IParameter|IQueryFunction|string $x Field in string format to be inspected by NOT LIKE() comparison. |
|
317 | - * @param mixed $y Argument to be used in NOT LIKE() comparison. |
|
318 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
319 | - * required when comparing text fields for oci compatibility |
|
320 | - * |
|
321 | - * @return string |
|
322 | - */ |
|
323 | - public function notLike($x, $y, $type = null): string { |
|
324 | - $x = $this->helper->quoteColumnName($x); |
|
325 | - $y = $this->helper->quoteColumnName($y); |
|
326 | - return $this->expressionBuilder->notLike($x, $y); |
|
327 | - } |
|
313 | + /** |
|
314 | + * Creates a NOT LIKE() comparison expression with the given arguments. |
|
315 | + * |
|
316 | + * @param ILiteral|IParameter|IQueryFunction|string $x Field in string format to be inspected by NOT LIKE() comparison. |
|
317 | + * @param mixed $y Argument to be used in NOT LIKE() comparison. |
|
318 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
319 | + * required when comparing text fields for oci compatibility |
|
320 | + * |
|
321 | + * @return string |
|
322 | + */ |
|
323 | + public function notLike($x, $y, $type = null): string { |
|
324 | + $x = $this->helper->quoteColumnName($x); |
|
325 | + $y = $this->helper->quoteColumnName($y); |
|
326 | + return $this->expressionBuilder->notLike($x, $y); |
|
327 | + } |
|
328 | 328 | |
329 | - /** |
|
330 | - * Creates a IN () comparison expression with the given arguments. |
|
331 | - * |
|
332 | - * @param ILiteral|IParameter|IQueryFunction|string $x The field in string format to be inspected by IN() comparison. |
|
333 | - * @param ILiteral|IParameter|IQueryFunction|string|array $y The placeholder or the array of values to be used by IN() comparison. |
|
334 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
335 | - * required when comparing text fields for oci compatibility |
|
336 | - * |
|
337 | - * @return string |
|
338 | - */ |
|
339 | - public function in($x, $y, $type = null): string { |
|
340 | - $x = $this->helper->quoteColumnName($x); |
|
341 | - $y = $this->helper->quoteColumnNames($y); |
|
342 | - return $this->expressionBuilder->in($x, $y); |
|
343 | - } |
|
329 | + /** |
|
330 | + * Creates a IN () comparison expression with the given arguments. |
|
331 | + * |
|
332 | + * @param ILiteral|IParameter|IQueryFunction|string $x The field in string format to be inspected by IN() comparison. |
|
333 | + * @param ILiteral|IParameter|IQueryFunction|string|array $y The placeholder or the array of values to be used by IN() comparison. |
|
334 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
335 | + * required when comparing text fields for oci compatibility |
|
336 | + * |
|
337 | + * @return string |
|
338 | + */ |
|
339 | + public function in($x, $y, $type = null): string { |
|
340 | + $x = $this->helper->quoteColumnName($x); |
|
341 | + $y = $this->helper->quoteColumnNames($y); |
|
342 | + return $this->expressionBuilder->in($x, $y); |
|
343 | + } |
|
344 | 344 | |
345 | - /** |
|
346 | - * Creates a NOT IN () comparison expression with the given arguments. |
|
347 | - * |
|
348 | - * @param ILiteral|IParameter|IQueryFunction|string $x The field in string format to be inspected by NOT IN() comparison. |
|
349 | - * @param ILiteral|IParameter|IQueryFunction|string|array $y The placeholder or the array of values to be used by NOT IN() comparison. |
|
350 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
351 | - * required when comparing text fields for oci compatibility |
|
352 | - * |
|
353 | - * @return string |
|
354 | - */ |
|
355 | - public function notIn($x, $y, $type = null): string { |
|
356 | - $x = $this->helper->quoteColumnName($x); |
|
357 | - $y = $this->helper->quoteColumnNames($y); |
|
358 | - return $this->expressionBuilder->notIn($x, $y); |
|
359 | - } |
|
345 | + /** |
|
346 | + * Creates a NOT IN () comparison expression with the given arguments. |
|
347 | + * |
|
348 | + * @param ILiteral|IParameter|IQueryFunction|string $x The field in string format to be inspected by NOT IN() comparison. |
|
349 | + * @param ILiteral|IParameter|IQueryFunction|string|array $y The placeholder or the array of values to be used by NOT IN() comparison. |
|
350 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
351 | + * required when comparing text fields for oci compatibility |
|
352 | + * |
|
353 | + * @return string |
|
354 | + */ |
|
355 | + public function notIn($x, $y, $type = null): string { |
|
356 | + $x = $this->helper->quoteColumnName($x); |
|
357 | + $y = $this->helper->quoteColumnNames($y); |
|
358 | + return $this->expressionBuilder->notIn($x, $y); |
|
359 | + } |
|
360 | 360 | |
361 | - /** |
|
362 | - * Creates a $x = '' statement, because Oracle needs a different check |
|
363 | - * |
|
364 | - * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be inspected by the comparison. |
|
365 | - * @return string |
|
366 | - * @since 13.0.0 |
|
367 | - */ |
|
368 | - public function emptyString($x): string { |
|
369 | - return $this->eq($x, $this->literal('', IQueryBuilder::PARAM_STR)); |
|
370 | - } |
|
361 | + /** |
|
362 | + * Creates a $x = '' statement, because Oracle needs a different check |
|
363 | + * |
|
364 | + * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be inspected by the comparison. |
|
365 | + * @return string |
|
366 | + * @since 13.0.0 |
|
367 | + */ |
|
368 | + public function emptyString($x): string { |
|
369 | + return $this->eq($x, $this->literal('', IQueryBuilder::PARAM_STR)); |
|
370 | + } |
|
371 | 371 | |
372 | - /** |
|
373 | - * Creates a `$x <> ''` statement, because Oracle needs a different check |
|
374 | - * |
|
375 | - * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be inspected by the comparison. |
|
376 | - * @return string |
|
377 | - * @since 13.0.0 |
|
378 | - */ |
|
379 | - public function nonEmptyString($x): string { |
|
380 | - return $this->neq($x, $this->literal('', IQueryBuilder::PARAM_STR)); |
|
381 | - } |
|
372 | + /** |
|
373 | + * Creates a `$x <> ''` statement, because Oracle needs a different check |
|
374 | + * |
|
375 | + * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be inspected by the comparison. |
|
376 | + * @return string |
|
377 | + * @since 13.0.0 |
|
378 | + */ |
|
379 | + public function nonEmptyString($x): string { |
|
380 | + return $this->neq($x, $this->literal('', IQueryBuilder::PARAM_STR)); |
|
381 | + } |
|
382 | 382 | |
383 | - /** |
|
384 | - * Binary AND Operator copies a bit to the result if it exists in both operands. |
|
385 | - * |
|
386 | - * @param string|ILiteral $x The field or value to check |
|
387 | - * @param int $y Bitmap that must be set |
|
388 | - * @return IQueryFunction |
|
389 | - * @since 12.0.0 |
|
390 | - */ |
|
391 | - public function bitwiseAnd($x, int $y): IQueryFunction { |
|
392 | - return new QueryFunction($this->connection->getDatabasePlatform()->getBitAndComparisonExpression( |
|
393 | - $this->helper->quoteColumnName($x), |
|
394 | - $y |
|
395 | - )); |
|
396 | - } |
|
383 | + /** |
|
384 | + * Binary AND Operator copies a bit to the result if it exists in both operands. |
|
385 | + * |
|
386 | + * @param string|ILiteral $x The field or value to check |
|
387 | + * @param int $y Bitmap that must be set |
|
388 | + * @return IQueryFunction |
|
389 | + * @since 12.0.0 |
|
390 | + */ |
|
391 | + public function bitwiseAnd($x, int $y): IQueryFunction { |
|
392 | + return new QueryFunction($this->connection->getDatabasePlatform()->getBitAndComparisonExpression( |
|
393 | + $this->helper->quoteColumnName($x), |
|
394 | + $y |
|
395 | + )); |
|
396 | + } |
|
397 | 397 | |
398 | - /** |
|
399 | - * Binary OR Operator copies a bit if it exists in either operand. |
|
400 | - * |
|
401 | - * @param string|ILiteral $x The field or value to check |
|
402 | - * @param int $y Bitmap that must be set |
|
403 | - * @return IQueryFunction |
|
404 | - * @since 12.0.0 |
|
405 | - */ |
|
406 | - public function bitwiseOr($x, int $y): IQueryFunction { |
|
407 | - return new QueryFunction($this->connection->getDatabasePlatform()->getBitOrComparisonExpression( |
|
408 | - $this->helper->quoteColumnName($x), |
|
409 | - $y |
|
410 | - )); |
|
411 | - } |
|
398 | + /** |
|
399 | + * Binary OR Operator copies a bit if it exists in either operand. |
|
400 | + * |
|
401 | + * @param string|ILiteral $x The field or value to check |
|
402 | + * @param int $y Bitmap that must be set |
|
403 | + * @return IQueryFunction |
|
404 | + * @since 12.0.0 |
|
405 | + */ |
|
406 | + public function bitwiseOr($x, int $y): IQueryFunction { |
|
407 | + return new QueryFunction($this->connection->getDatabasePlatform()->getBitOrComparisonExpression( |
|
408 | + $this->helper->quoteColumnName($x), |
|
409 | + $y |
|
410 | + )); |
|
411 | + } |
|
412 | 412 | |
413 | - /** |
|
414 | - * Quotes a given input parameter. |
|
415 | - * |
|
416 | - * @param mixed $input The parameter to be quoted. |
|
417 | - * @param int $type One of the IQueryBuilder::PARAM_* constants |
|
418 | - * |
|
419 | - * @return ILiteral |
|
420 | - */ |
|
421 | - public function literal($input, $type = IQueryBuilder::PARAM_STR): ILiteral { |
|
422 | - return new Literal($this->expressionBuilder->literal($input, $type)); |
|
423 | - } |
|
413 | + /** |
|
414 | + * Quotes a given input parameter. |
|
415 | + * |
|
416 | + * @param mixed $input The parameter to be quoted. |
|
417 | + * @param int $type One of the IQueryBuilder::PARAM_* constants |
|
418 | + * |
|
419 | + * @return ILiteral |
|
420 | + */ |
|
421 | + public function literal($input, $type = IQueryBuilder::PARAM_STR): ILiteral { |
|
422 | + return new Literal($this->expressionBuilder->literal($input, $type)); |
|
423 | + } |
|
424 | 424 | |
425 | - /** |
|
426 | - * Returns a IQueryFunction that casts the column to the given type |
|
427 | - * |
|
428 | - * @param string|IQueryFunction $column |
|
429 | - * @param mixed $type One of IQueryBuilder::PARAM_* |
|
430 | - * @psalm-param IQueryBuilder::PARAM_* $type |
|
431 | - * @return IQueryFunction |
|
432 | - */ |
|
433 | - public function castColumn($column, $type): IQueryFunction { |
|
434 | - return new QueryFunction( |
|
435 | - $this->helper->quoteColumnName($column) |
|
436 | - ); |
|
437 | - } |
|
425 | + /** |
|
426 | + * Returns a IQueryFunction that casts the column to the given type |
|
427 | + * |
|
428 | + * @param string|IQueryFunction $column |
|
429 | + * @param mixed $type One of IQueryBuilder::PARAM_* |
|
430 | + * @psalm-param IQueryBuilder::PARAM_* $type |
|
431 | + * @return IQueryFunction |
|
432 | + */ |
|
433 | + public function castColumn($column, $type): IQueryFunction { |
|
434 | + return new QueryFunction( |
|
435 | + $this->helper->quoteColumnName($column) |
|
436 | + ); |
|
437 | + } |
|
438 | 438 | } |