ComparisonExpression
    
            
            in package
            
        
    
            
            implements
                            ExpressionInterface,                             FieldInterface                    
    
            
            uses
                            ExpressionTypeCasterTrait,                             FieldTrait                    
    
A Comparison is a type of query expression that represents an operation involving a field an operator and a value. In its most common form the string representation of a comparison is `field = value`
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
- $_isMultiple : bool
- Whether the value in this expression is a traversable
- $_operator : string
- The operator used for comparing field and value
- $_type : string|null
- The type to be used for casting the value to a database representation
- $_value : mixed
- The value to be used in the right hand side of the operation
- $_valueExpressions : array<string|int, ExpressionInterface>
- A cached list of ExpressionInterface objects that were found in the value for this expression.
Methods
- __clone() : void
- Create a deep clone.
- __construct() : mixed
- Constructor
- getField() : ExpressionInterface|array<string|int, mixed>|string
- Returns the field name
- getOperator() : string
- Returns the operator used for comparison
- getValue() : mixed
- Returns the value used for comparison
- setField() : void
- Sets the field name
- setOperator() : void
- Sets the operator to use for the comparison
- setValue() : void
- Sets the value
- 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.
- _collectExpressions() : array<string|int, mixed>
- Returns an array with the original $values in the first position and all ExpressionInterface objects that could be found in the second position.
- _flattenValue() : string
- Converts a traversable value into a set of placeholders generated by $binder and separated by `,`
- _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.
- _stringExpression() : array<string|int, mixed>
- Returns a template and a placeholder for the value after registering it with the placeholder $binder
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
    
    
    
    
    
$_isMultiple
Whether the value in this expression is a traversable
    protected
        bool
    $_isMultiple
     = false
    
    
    
    
$_operator
The operator used for comparing field and value
    protected
        string
    $_operator
     = '='
    
    
    
    
$_type
The type to be used for casting the value to a database representation
    protected
        string|null
    $_type
    
    
    
    
    
$_value
The value to be used in the right hand side of the operation
    protected
        mixed
    $_value
    
    
    
    
    
$_valueExpressions
A cached list of ExpressionInterface objects that were found in the value for this expression.
    protected
        array<string|int, ExpressionInterface>
    $_valueExpressions
     = []
    
    
    
    
Methods
__clone()
Create a deep clone.
    public
                    __clone() : void
    Clones the field and value if they are expression objects.
__construct()
Constructor
    public
                    __construct(ExpressionInterface|string $field, mixed $value[, string|null $type = null ][, string $operator = '=' ]) : mixed
    Parameters
- $field : ExpressionInterface|string
- 
                    the field name to compare to a value 
- $value : mixed
- 
                    The value to be used in comparison 
- $type : string|null = null
- 
                    the type name used to cast the value 
- $operator : string = '='
- 
                    the operator used for comparing field and value 
getField()
Returns the field name
    public
                    getField() : ExpressionInterface|array<string|int, mixed>|string
    Return values
ExpressionInterface|array<string|int, mixed>|stringgetOperator()
Returns the operator used for comparison
    public
                    getOperator() : string
    Return values
stringgetValue()
Returns the value used for comparison
    public
                    getValue() : mixed
    setField()
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. 
setOperator()
Sets the operator to use for the comparison
    public
                    setOperator(string $operator) : void
    Parameters
- $operator : string
- 
                    The operator to be used for the comparison. 
setValue()
Sets the value
    public
                    setValue(mixed $value) : void
    Parameters
- $value : mixed
- 
                    The value to compare 
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|null $type = null ]) : string
    Parameters
- $value : mixed
- 
                    The value to bind 
- $binder : ValueBinder
- 
                    The value binder to use 
- $type : string|null = null
- 
                    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 
_collectExpressions()
Returns an array with the original $values in the first position and all ExpressionInterface objects that could be found in the second position.
    protected
                    _collectExpressions(ExpressionInterface|iterable<string|int, mixed> $values) : array<string|int, mixed>
    Parameters
- $values : ExpressionInterface|iterable<string|int, mixed>
- 
                    The rows to insert 
Return values
array<string|int, mixed>_flattenValue()
Converts a traversable value into a set of placeholders generated by $binder and separated by `,`
    protected
                    _flattenValue(iterable<string|int, mixed> $value, ValueBinder $binder[, string|null $type = null ]) : string
    Parameters
- $value : iterable<string|int, mixed>
- 
                    the value to flatten 
- $binder : ValueBinder
- 
                    The value binder to use 
- $type : string|null = null
- 
                    the type to cast values to 
Return values
string_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 
Return values
array<string|int, mixed>_stringExpression()
Returns a template and a placeholder for the value after registering it with the placeholder $binder
    protected
                    _stringExpression(ValueBinder $binder) : array<string|int, mixed>
    Parameters
- $binder : ValueBinder
- 
                    The value binder to use. 
Return values
array<string|int, mixed> —First position containing the template and the second a placeholder