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
string|array|\Cake\Database\ExpressionInterface
The field name or expression to be used in the left hand side of the operator
bool
Whether or not the value in this expression is a traversable
string
The operator used for comparing field and value
string|null
The type to be used for casting the value to a database representation
mixed
The value to be used in the right hand side of the operation
\Cake\Database\ExpressionInterface[]
A cached list of ExpressionInterface objects that were found in the value for this expression.
Registers a value in the placeholder generator and returns the generated placeholder
Conditionally converts the passed value to an ExpressionInterface object if the type class implements the ExpressionTypeInterface. Otherwise, returns the value unmodified.
Returns an array with the original $values in the first position and all ExpressionInterface objects that could be found in the second position.
Converts a traversable value into a set of placeholders generated by $generator and separated by ,
Returns an array with the types that require values to be casted to expressions, out of the list of type names passed as parameter.
Returns a template and a placeholder for the value after registering it with the placeholder $generator
Iterates over each part of the expression recursively for every level of the expressions tree and executes the $visitor callable passing as first parameter the instance of the expression currently being iterated.
__clone()
Create a deep clone.
Clones the field and value if they are expression objects.
__construct(mixed $field, mixed $value, ?string $type, string $operator)
Constructor
string|\Cake\Database\ExpressionInterface
$field the field name to compare to a value
mixed
$value The value to be used in comparison
string|null
$type optional the type name used to cast the value
string
$operator optional the operator used for comparing field and value
_bindValue(mixed $value, \Cake\Database\ValueBinder $generator, ?string $type)
Registers a value in the placeholder generator and returns the generated placeholder
mixed
$value The value to bind
\Cake\Database\ValueBinder
$generator The value binder to use
string|null
$type optional The type of $value
string
generated placeholder
_castToExpression(mixed $value, ?string $type)
Conditionally converts the passed value to an ExpressionInterface object if the type class implements the ExpressionTypeInterface. Otherwise, returns the value unmodified.
mixed
$value The value to converto to ExpressionInterface
string|null
$type optional The type name
mixed
_collectExpressions(mixed $values)
Returns an array with the original $values in the first position and all ExpressionInterface objects that could be found in the second position.
iterable|\Cake\Database\ExpressionInterface
$values The rows to insert
array
_flattenValue(iterable $value, \Cake\Database\ValueBinder $generator, ?string $type)
Converts a traversable value into a set of placeholders generated by $generator and separated by ,
iterable
$value the value to flatten
\Cake\Database\ValueBinder
$generator The value binder to use
string|null
$type optional the type to cast values to
string
_requiresToExpressionCasting(array $types)
Returns an array with the types that require values to be casted to expressions, out of the list of type names passed as parameter.
array
$types List of type names
array
_stringExpression(\Cake\Database\ValueBinder $generator)
Returns a template and a placeholder for the value after registering it with the placeholder $generator
\Cake\Database\ValueBinder
$generator The value binder to use.
array
First position containing the template and the second a placeholder
getField()
Returns the field name
string|array|\Cake\Database\ExpressionInterface
getOperator()
Returns the operator used for comparison
string
getValue()
Returns the value used for comparison
mixed
setField(mixed $field)
Sets the field name
string|array|\Cake\Database\ExpressionInterface
$field The field to compare with.
setOperator(string $operator)
Sets the operator to use for the comparison
string
$operator The operator to be used for the comparison.
setValue(mixed $value)
Sets the value
mixed
$value The value to compare
sql(\Cake\Database\ValueBinder $generator)
Convert the expression into a SQL fragment.
\Cake\Database\ValueBinder
$generator Placeholder generator object
string
traverse(\Closure $visitor)
Iterates over each part of the expression recursively for every level of the expressions tree and executes the $visitor callable passing as first parameter the instance of the expression currently being iterated.
\Closure
$visitor The callable to apply to all nodes.
$this
The field name or expression to be used in the left hand side of the operator
string|array|\Cake\Database\ExpressionInterface
Whether or not the value in this expression is a traversable
bool
The operator used for comparing field and value
string
The type to be used for casting the value to a database representation
string|null
The value to be used in the right hand side of the operation
mixed
A cached list of ExpressionInterface objects that were found in the value for this expression.
\Cake\Database\ExpressionInterface[]
© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.1/class-Cake.Database.Expression.ComparisonExpression.html