"helm/git@forgeb1.univ-lehavre.fr:bm222079/fullstacktaxe.git" n'existait pas sur "03238d1001ca4e91158a4f02355cf9aab819f522"
Newer
Older
Klaranouba7
a validé
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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
<?php
namespace Doctrine\DBAL\Query\Expression;
use Doctrine\DBAL\Connection;
use Doctrine\Deprecations\Deprecation;
use function func_get_arg;
use function func_get_args;
use function func_num_args;
use function implode;
use function sprintf;
/**
* ExpressionBuilder class is responsible to dynamically create SQL query parts.
*/
class ExpressionBuilder
{
public const EQ = '=';
public const NEQ = '<>';
public const LT = '<';
public const LTE = '<=';
public const GT = '>';
public const GTE = '>=';
/**
* The DBAL Connection.
*
* @var Connection
*/
private $connection;
/**
* Initializes a new <tt>ExpressionBuilder</tt>.
*
* @param Connection $connection The DBAL Connection.
*/
public function __construct(Connection $connection)
{
$this->connection = $connection;
}
/**
* Creates a conjunction of the given expressions.
*
* @param string|CompositeExpression $expression
* @param string|CompositeExpression ...$expressions
*/
public function and($expression, ...$expressions): CompositeExpression
{
return CompositeExpression::and($expression, ...$expressions);
}
/**
* Creates a disjunction of the given expressions.
*
* @param string|CompositeExpression $expression
* @param string|CompositeExpression ...$expressions
*/
public function or($expression, ...$expressions): CompositeExpression
{
return CompositeExpression::or($expression, ...$expressions);
}
/**
* @deprecated Use `and()` instead.
*
* @param mixed $x Optional clause. Defaults = null, but requires
* at least one defined when converting to string.
*
* @return CompositeExpression
*/
public function andX($x = null)
{
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/3851',
'ExpressionBuilder::andX() is deprecated, use ExpressionBuilder::and() instead.'
);
return new CompositeExpression(CompositeExpression::TYPE_AND, func_get_args());
}
/**
* @deprecated Use `or()` instead.
*
* @param mixed $x Optional clause. Defaults = null, but requires
* at least one defined when converting to string.
*
* @return CompositeExpression
*/
public function orX($x = null)
{
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/3851',
'ExpressionBuilder::orX() is deprecated, use ExpressionBuilder::or() instead.'
);
return new CompositeExpression(CompositeExpression::TYPE_OR, func_get_args());
}
/**
* Creates a comparison expression.
*
* @param mixed $x The left expression.
* @param string $operator One of the ExpressionBuilder::* constants.
* @param mixed $y The right expression.
*
* @return string
*/
public function comparison($x, $operator, $y)
{
return $x . ' ' . $operator . ' ' . $y;
}
/**
* Creates an equality comparison expression with the given arguments.
*
* First argument is considered the left expression and the second is the right expression.
* When converted to string, it will generated a <left expr> = <right expr>. Example:
*
* [php]
* // u.id = ?
* $expr->eq('u.id', '?');
*
* @param mixed $x The left expression.
* @param mixed $y The right expression.
*
* @return string
*/
public function eq($x, $y)
{
return $this->comparison($x, self::EQ, $y);
}
/**
* Creates a non equality comparison expression with the given arguments.
* First argument is considered the left expression and the second is the right expression.
* When converted to string, it will generated a <left expr> <> <right expr>. Example:
*
* [php]
* // u.id <> 1
* $q->where($q->expr()->neq('u.id', '1'));
*
* @param mixed $x The left expression.
* @param mixed $y The right expression.
*
* @return string
*/
public function neq($x, $y)
{
return $this->comparison($x, self::NEQ, $y);
}
/**
* Creates a lower-than comparison expression with the given arguments.
* First argument is considered the left expression and the second is the right expression.
* When converted to string, it will generated a <left expr> < <right expr>. Example:
*
* [php]
* // u.id < ?
* $q->where($q->expr()->lt('u.id', '?'));
*
* @param mixed $x The left expression.
* @param mixed $y The right expression.
*
* @return string
*/
public function lt($x, $y)
{
return $this->comparison($x, self::LT, $y);
}
/**
* Creates a lower-than-equal comparison expression with the given arguments.
* First argument is considered the left expression and the second is the right expression.
* When converted to string, it will generated a <left expr> <= <right expr>. Example:
*
* [php]
* // u.id <= ?
* $q->where($q->expr()->lte('u.id', '?'));
*
* @param mixed $x The left expression.
* @param mixed $y The right expression.
*
* @return string
*/
public function lte($x, $y)
{
return $this->comparison($x, self::LTE, $y);
}
/**
* Creates a greater-than comparison expression with the given arguments.
* First argument is considered the left expression and the second is the right expression.
* When converted to string, it will generated a <left expr> > <right expr>. Example:
*
* [php]
* // u.id > ?
* $q->where($q->expr()->gt('u.id', '?'));
*
* @param mixed $x The left expression.
* @param mixed $y The right expression.
*
* @return string
*/
public function gt($x, $y)
{
return $this->comparison($x, self::GT, $y);
}
/**
* Creates a greater-than-equal comparison expression with the given arguments.
* First argument is considered the left expression and the second is the right expression.
* When converted to string, it will generated a <left expr> >= <right expr>. Example:
*
* [php]
* // u.id >= ?
* $q->where($q->expr()->gte('u.id', '?'));
*
* @param mixed $x The left expression.
* @param mixed $y The right expression.
*
* @return string
*/
public function gte($x, $y)
{
return $this->comparison($x, self::GTE, $y);
}
/**
* Creates an IS NULL expression with the given arguments.
*
* @param string $x The expression to be restricted by IS NULL.
*
* @return string
*/
public function isNull($x)
{
return $x . ' IS NULL';
}
/**
* Creates an IS NOT NULL expression with the given arguments.
*
* @param string $x The expression to be restricted by IS NOT NULL.
*
* @return string
*/
public function isNotNull($x)
{
return $x . ' IS NOT NULL';
}
/**
* Creates a LIKE() comparison expression with the given arguments.
*
* @param string $x The expression to be inspected by the LIKE comparison
* @param mixed $y The pattern to compare against
*
* @return string
*/
public function like($x, $y/*, ?string $escapeChar = null */)
{
return $this->comparison($x, 'LIKE', $y) .
(func_num_args() >= 3 ? sprintf(' ESCAPE %s', func_get_arg(2)) : '');
}
/**
* Creates a NOT LIKE() comparison expression with the given arguments.
*
* @param string $x The expression to be inspected by the NOT LIKE comparison
* @param mixed $y The pattern to compare against
*
* @return string
*/
public function notLike($x, $y/*, ?string $escapeChar = null */)
{
return $this->comparison($x, 'NOT LIKE', $y) .
(func_num_args() >= 3 ? sprintf(' ESCAPE %s', func_get_arg(2)) : '');
}
/**
* Creates an IN () comparison expression with the given arguments.
*
* @param string $x The SQL expression to be matched against the set.
* @param string|string[] $y The SQL expression or an array of SQL expressions representing the set.
*
* @return string
*/
public function in($x, $y)
{
return $this->comparison($x, 'IN', '(' . implode(', ', (array) $y) . ')');
}
/**
* Creates a NOT IN () comparison expression with the given arguments.
*
* @param string $x The SQL expression to be matched against the set.
* @param string|string[] $y The SQL expression or an array of SQL expressions representing the set.
*
* @return string
*/
public function notIn($x, $y)
{
return $this->comparison($x, 'NOT IN', '(' . implode(', ', (array) $y) . ')');
}
/**
* Builds an SQL literal from a given input parameter.
*
* The usage of this method is discouraged. Use prepared statements
* or {@link AbstractPlatform::quoteStringLiteral()} instead.
*
* @param mixed $input The parameter to be quoted.
* @param int|null $type The type of the parameter.
*
* @return string
*/
public function literal($input, $type = null)
{
return $this->connection->quote($input, $type);
}
}