ExpressionBuilder
in package
ExpressionBuilder class is responsible to dynamically create SQL query parts.
Table of Contents
Constants
Properties
- $connection : Connection
- The DBAL Connection.
Methods
- __construct() : mixed
- Initializes a new <tt>ExpressionBuilder</tt>.
- and() : CompositeExpression
- Creates a conjunction of the given expressions.
- andX() : CompositeExpression
- comparison() : string
- Creates a comparison expression.
- eq() : string
- Creates an equality comparison expression with the given arguments.
- gt() : string
- Creates a greater-than comparison expression with the given arguments.
- gte() : string
- Creates a greater-than-equal comparison expression with the given arguments.
- in() : string
- Creates an IN () comparison expression with the given arguments.
- isNotNull() : string
- Creates an IS NOT NULL expression with the given arguments.
- isNull() : string
- Creates an IS NULL expression with the given arguments.
- like() : string
- Creates a LIKE() comparison expression with the given arguments.
- literal() : string
- Builds an SQL literal from a given input parameter.
- lt() : string
- Creates a lower-than comparison expression with the given arguments.
- lte() : string
- Creates a lower-than-equal comparison expression with the given arguments.
- neq() : string
- Creates a non equality comparison expression with the given arguments.
- notIn() : string
- Creates a NOT IN () comparison expression with the given arguments.
- notLike() : string
- Creates a NOT LIKE() comparison expression with the given arguments.
- or() : CompositeExpression
- Creates a disjunction of the given expressions.
- orX() : CompositeExpression
Constants
EQ
public
mixed
EQ
= '='
GT
public
mixed
GT
= '>'
GTE
public
mixed
GTE
= '>='
LT
public
mixed
LT
= '<'
LTE
public
mixed
LTE
= '<='
NEQ
public
mixed
NEQ
= '<>'
Properties
$connection
The DBAL Connection.
private
Connection
$connection
Methods
__construct()
Initializes a new <tt>ExpressionBuilder</tt>.
public
__construct(Connection $connection) : mixed
Parameters
- $connection : Connection
-
The DBAL Connection.
and()
Creates a conjunction of the given expressions.
public
and(string|CompositeExpression $expression, string|CompositeExpression ...$expressions) : CompositeExpression
Parameters
- $expression : string|CompositeExpression
- $expressions : string|CompositeExpression
Return values
CompositeExpressionandX()
public
andX([mixed $x = null ]) : CompositeExpression
Parameters
- $x : mixed = null
-
Optional clause. Defaults = null, but requires at least one defined when converting to string.
Tags
Return values
CompositeExpressioncomparison()
Creates a comparison expression.
public
comparison(mixed $x, string $operator, mixed $y) : string
Parameters
- $x : mixed
-
The left expression.
- $operator : string
-
One of the ExpressionBuilder::* constants.
- $y : mixed
-
The right expression.
Return values
stringeq()
Creates an equality comparison expression with the given arguments.
public
eq(mixed $x, mixed $y) : string
First argument is considered the left expression and the second is the right expression.
When converted to string, it will generated a
[php]
// u.id = ?
$expr->eq('u.id', '?');
Parameters
- $x : mixed
-
The left expression.
- $y : mixed
-
The right expression.
Return values
stringgt()
Creates a greater-than comparison expression with the given arguments.
public
gt(mixed $x, mixed $y) : string
First argument is considered the left expression and the second is the right expression.
When converted to string, it will generated a
[php]
// u.id > ?
$q->where($q->expr()->gt('u.id', '?'));
Parameters
- $x : mixed
-
The left expression.
- $y : mixed
-
The right expression.
Return values
stringgte()
Creates a greater-than-equal comparison expression with the given arguments.
public
gte(mixed $x, mixed $y) : string
First argument is considered the left expression and the second is the right expression.
When converted to string, it will generated a
[php]
// u.id >= ?
$q->where($q->expr()->gte('u.id', '?'));
Parameters
- $x : mixed
-
The left expression.
- $y : mixed
-
The right expression.
Return values
stringin()
Creates an IN () comparison expression with the given arguments.
public
in(string $x, string|array<string|int, string> $y) : string
Parameters
- $x : string
-
The SQL expression to be matched against the set.
- $y : string|array<string|int, string>
-
The SQL expression or an array of SQL expressions representing the set.
Return values
stringisNotNull()
Creates an IS NOT NULL expression with the given arguments.
public
isNotNull(string $x) : string
Parameters
- $x : string
-
The expression to be restricted by IS NOT NULL.
Return values
stringisNull()
Creates an IS NULL expression with the given arguments.
public
isNull(string $x) : string
Parameters
- $x : string
-
The expression to be restricted by IS NULL.
Return values
stringlike()
Creates a LIKE() comparison expression with the given arguments.
public
like(string $x, mixed $y) : string
Parameters
- $x : string
-
The expression to be inspected by the LIKE comparison
- $y : mixed
-
The pattern to compare against
Return values
stringliteral()
Builds an SQL literal from a given input parameter.
public
literal(mixed $input[, int|null $type = null ]) : string
The usage of this method is discouraged. Use prepared statements or AbstractPlatform::quoteStringLiteral() instead.
Parameters
- $input : mixed
-
The parameter to be quoted.
- $type : int|null = null
-
The type of the parameter.
Return values
stringlt()
Creates a lower-than comparison expression with the given arguments.
public
lt(mixed $x, mixed $y) : string
First argument is considered the left expression and the second is the right expression.
When converted to string, it will generated a
[php]
// u.id < ?
$q->where($q->expr()->lt('u.id', '?'));
Parameters
- $x : mixed
-
The left expression.
- $y : mixed
-
The right expression.
Return values
stringlte()
Creates a lower-than-equal comparison expression with the given arguments.
public
lte(mixed $x, mixed $y) : string
First argument is considered the left expression and the second is the right expression.
When converted to string, it will generated a
[php]
// u.id <= ?
$q->where($q->expr()->lte('u.id', '?'));
Parameters
- $x : mixed
-
The left expression.
- $y : mixed
-
The right expression.
Return values
stringneq()
Creates a non equality comparison expression with the given arguments.
public
neq(mixed $x, mixed $y) : string
First argument is considered the left expression and the second is the right expression.
When converted to string, it will generated a
[php]
// u.id <> 1
$q->where($q->expr()->neq('u.id', '1'));
Parameters
- $x : mixed
-
The left expression.
- $y : mixed
-
The right expression.
Return values
stringnotIn()
Creates a NOT IN () comparison expression with the given arguments.
public
notIn(string $x, string|array<string|int, string> $y) : string
Parameters
- $x : string
-
The SQL expression to be matched against the set.
- $y : string|array<string|int, string>
-
The SQL expression or an array of SQL expressions representing the set.
Return values
stringnotLike()
Creates a NOT LIKE() comparison expression with the given arguments.
public
notLike(string $x, mixed $y) : string
Parameters
- $x : string
-
The expression to be inspected by the NOT LIKE comparison
- $y : mixed
-
The pattern to compare against
Return values
stringor()
Creates a disjunction of the given expressions.
public
or(string|CompositeExpression $expression, string|CompositeExpression ...$expressions) : CompositeExpression
Parameters
- $expression : string|CompositeExpression
- $expressions : string|CompositeExpression
Return values
CompositeExpressionorX()
public
orX([mixed $x = null ]) : CompositeExpression
Parameters
- $x : mixed = null
-
Optional clause. Defaults = null, but requires at least one defined when converting to string.