BetweenExpression
in package
implements
ExpressionInterface, FieldInterface
uses
ExpressionTypeCasterTrait, FieldTrait
An expression object that represents a SQL BETWEEN snippet
Table of Contents
Interfaces
- ExpressionInterface
- An interface used by Expression objects.
- FieldInterface
- Describes a getter and a setter for the a field property. Useful for expressions that contain an identifier to compare against.
Properties
- $_field : ExpressionInterface|array<string|int, mixed>|string
- The field name or expression to be used in the left hand side of the operator
- $_from : mixed
- The first value in the expression
- $_to : mixed
- The second value in the expression
- $_type : mixed
- The data type for the from and to arguments
Methods
- __clone() : void
- Do a deep clone of this expression.
- __construct() : mixed
- Constructor
- getField() : ExpressionInterface|array<string|int, mixed>|string
- Returns the field name
- setField() : void
- Sets the field name
- sql() : string
- Converts the Node into a SQL string fragment.
- traverse() : $this
- Iterates over each part of the expression recursively for every level of the expressions tree and executes the $callback callable passing as first parameter the instance of the expression currently being iterated.
- _bindValue() : string
- Registers a value in the placeholder generator and returns the generated placeholder
- _castToExpression() : mixed
- Conditionally converts the passed value to an ExpressionInterface object if the type class implements the ExpressionTypeInterface. Otherwise, returns the value unmodified.
- _requiresToExpressionCasting() : array<string|int, mixed>
- Returns an array with the types that require values to be casted to expressions, out of the list of type names passed as parameter.
Properties
$_field
The field name or expression to be used in the left hand side of the operator
protected
ExpressionInterface|array<string|int, mixed>|string
$_field
$_from
The first value in the expression
protected
mixed
$_from
$_to
The second value in the expression
protected
mixed
$_to
$_type
The data type for the from and to arguments
protected
mixed
$_type
Methods
__clone()
Do a deep clone of this expression.
public
__clone() : void
__construct()
Constructor
public
__construct(ExpressionInterface|string $field, mixed $from, mixed $to[, string|null $type = null ]) : mixed
Parameters
- $field : ExpressionInterface|string
-
The field name to compare for values inbetween the range.
- $from : mixed
-
The initial value of the range.
- $to : mixed
-
The ending value in the comparison range.
- $type : string|null = null
-
The data type name to bind the values with.
getField()
Returns the field name
public
getField() : ExpressionInterface|array<string|int, mixed>|string
Return values
ExpressionInterface|array<string|int, mixed>|stringsetField()
Sets the field name
public
setField(ExpressionInterface|array<string|int, mixed>|string $field) : void
Parameters
- $field : ExpressionInterface|array<string|int, mixed>|string
-
The field to compare with.
sql()
Converts the Node into a SQL string fragment.
public
sql(ValueBinder $binder) : string
Parameters
- $binder : ValueBinder
-
Parameter binder
Tags
Return values
stringtraverse()
Iterates over each part of the expression recursively for every level of the expressions tree and executes the $callback callable passing as first parameter the instance of the expression currently being iterated.
public
traverse(Closure $callback) : $this
Parameters
- $callback : Closure
-
The callable to apply to all nodes.
Tags
Return values
$this_bindValue()
Registers a value in the placeholder generator and returns the generated placeholder
protected
_bindValue(mixed $value, ValueBinder $binder, string $type) : string
Parameters
- $value : mixed
-
The value to bind
- $binder : ValueBinder
-
The value binder to use
- $type : string
-
The type of $value
Return values
string —generated placeholder
_castToExpression()
Conditionally converts the passed value to an ExpressionInterface object if the type class implements the ExpressionTypeInterface. Otherwise, returns the value unmodified.
protected
_castToExpression(mixed $value[, string|null $type = null ]) : mixed
Parameters
- $value : mixed
-
The value to convert to ExpressionInterface
- $type : string|null = null
-
The type name
_requiresToExpressionCasting()
Returns an array with the types that require values to be casted to expressions, out of the list of type names passed as parameter.
protected
_requiresToExpressionCasting(array<string|int, mixed> $types) : array<string|int, mixed>
Parameters
- $types : array<string|int, mixed>
-
List of type names