Class TupleComparison
This expression represents SQL fragments that are used for comparing one tuple to another, one tuple to a set of other tuples or one tuple to an expression
Property Summary
-
$_field protected
string
The field name or expression to be used in the left hand side of the operator
-
$_operator protected
string
The operator used for comparing field and value
-
$_type protected
string
The type to be used for casting the value to a database representation
-
$_value protected
mixed
The value to be used in the right hand side of the operation
Method Summary
-
__clone() public
Create a deep clone.
-
__construct() public
Constructor
-
_bindValue() protected
Registers a value in the placeholder generator and returns the generated placeholder
-
_flattenValue() protected
Converts a traversable value into a set of placeholders generated by $generator and separated by
,
-
_stringExpression() protected
Returns a template and a placeholder for the value after registering it with the placeholder $generator
-
_stringifyValues() protected
Returns a string with the values as placeholders in a string to be used for the SQL version of this expression
-
_traverseValue() protected
Conditionally executes the callback for the passed value if it is an ExpressionInterface
-
getField() public
Returns the field name
-
getOperator() public
Returns the operator used for comparison
-
getValue() public
Returns the value used for comparison
-
isMulti() public
Determines if each of the values in this expressions is a tuple in itself
-
setField() public
Sets the field name
-
setOperator() public
Sets the operator to use for the comparison
-
setValue() public
Sets the value
-
sql() public
Convert the expression into a SQL fragment.
-
traverse() public
Traverses the tree of expressions stored in this object, visiting first expressions in the left hand side and then the rest.
Method Detail
__clone() ¶ public
__clone(): void
Create a deep clone.
Clones the field and value if they are expression objects.
Returns
void
__construct() ¶ public
__construct(string|array $fields, arrayCake\Database\ExpressionInterface $values, array $types = [], string $conjunction = '=')
Constructor
Parameters
-
string|array
$fields the fields to use to form a tuple
-
arrayCake\Database\ExpressionInterface
$values the values to use to form a tuple
-
array
$types optional the types names to use for casting each of the values, only one type per position in the value array in needed
-
string
$conjunction optional the operator used for comparing field and value
_bindValue() ¶ protected
_bindValue(Cake\Database\ValueBinder $generator, mixed $value, string $type): string
Registers a value in the placeholder generator and returns the generated placeholder
Parameters
-
Cake\Database\ValueBinder
$generator The value binder
-
mixed
$value The value to bind
-
string
$type The type to use
Returns
string
_flattenValue() ¶ protected
_flattenValue(arrayTraversable $value, Cake\Database\ValueBinder $generator, string|array|null $type = null): string
Converts a traversable value into a set of placeholders generated by
$generator and separated by ,
Parameters
-
arrayTraversable
$value the value to flatten
-
Cake\Database\ValueBinder
$generator The value binder to use
-
string|array|null
$type optional the type to cast values to
Returns
string
_stringExpression() ¶ protected
_stringExpression(Cake\Database\ValueBinder $generator): array
Returns a template and a placeholder for the value after registering it with the placeholder $generator
Parameters
-
Cake\Database\ValueBinder
$generator The value binder to use.
Returns
array
_stringifyValues() ¶ protected
_stringifyValues(Cake\Database\ValueBinder $generator): string
Returns a string with the values as placeholders in a string to be used for the SQL version of this expression
Parameters
-
Cake\Database\ValueBinder
$generator The value binder to convert expressions with.
Returns
string
_traverseValue() ¶ protected
_traverseValue(mixed $value, callable $callable): void
Conditionally executes the callback for the passed value if it is an ExpressionInterface
Parameters
-
mixed
$value The value to traverse
-
callable
$callable The callable to use when traversing
Returns
void
getField() ¶ public
getField(): stringCake\Database\ExpressionInterface
Returns the field name
Returns
stringCake\Database\ExpressionInterface
getOperator() ¶ public
getOperator(): string
Returns the operator used for comparison
Returns
string
isMulti() ¶ public
isMulti(): bool
Determines if each of the values in this expressions is a tuple in itself
Returns
bool
setField() ¶ public
setField(string $field): void
Sets the field name
Parameters
-
string
$field The field to compare with.
Returns
void
setOperator() ¶ public
setOperator(string $operator): void
Sets the operator to use for the comparison
Parameters
-
string
$operator The operator to be used for the comparison.
Returns
void
setValue() ¶ public
setValue(mixed $value): void
Sets the value
Parameters
-
mixed
$value The value to compare
Returns
void
sql() ¶ public
sql(Cake\Database\ValueBinder $generator): string
Convert the expression into a SQL fragment.
Parameters
-
Cake\Database\ValueBinder
$generator Placeholder generator object
Returns
string
traverse() ¶ public
traverse(callable $callable): void
Traverses the tree of expressions stored in this object, visiting first expressions in the left hand side and then the rest.
Callback function receives as its only argument an instance of an ExpressionInterface
Parameters
-
callable
$callable The callable to apply to sub-expressions
Returns
void