\Cake\Database\ExpressionTupleComparison

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

Summary

Methods
Properties
Constants
__construct()
setValue()
getValue()
setOperator()
getOperator()
sql()
traverse()
__clone()
setField()
getField()
isMulti()
No public properties found
No constants found
_stringExpression()
_bindValue()
_flattenValue()
_collectExpressions()
_castToExpression()
_requiresToExpressionCasting()
_stringifyValues()
_traverseValue()
$_value
$_type
$_operator
$_isMultiple
$_valueExpressions
$_field
N/A
No private methods found
No private properties found
N/A

Properties

$_value

$_value : mixed

The value to be used in the right hand side of the operation

Type

mixed

$_type

$_type : string|array

The type to be used for casting the value to a database representation

Type

string|array

$_operator

$_operator : string

The operator used for comparing field and value

Type

string

$_isMultiple

$_isMultiple : boolean

Whether or not the value in this expression is a traversable

Type

boolean

$_valueExpressions

$_valueExpressions : array<mixed,\Cake\Database\ExpressionInterface>

A cached list of ExpressionInterface objects that were found in the value for this expression.

Type

array<mixed,\Cake\Database\ExpressionInterface>

$_field

$_field : string|\Cake\Database\ExpressionInterface

The field name or expression to be used in the left hand side of the operator

Type

string|\Cake\Database\ExpressionInterface

Methods

__construct()

__construct(string|array|\Cake\Database\ExpressionInterface  $fields, array|\Cake\Database\ExpressionInterface  $values, array  $types = array(), string  $conjunction = '=') 

Constructor

Parameters

string|array|\Cake\Database\ExpressionInterface $fields

the fields to use to form a tuple

array|\Cake\Database\ExpressionInterface $values

the values to use to form a tuple

array $types

the types names to use for casting each of the values, only one type per position in the value array in needed

string $conjunction

the operator used for comparing field and value

setValue()

setValue(mixed  $value) : void

Sets the value

Parameters

mixed $value

The value to compare

getValue()

getValue() : mixed

Returns the value used for comparison

Returns

mixed

setOperator()

setOperator(string  $operator) : void

Sets the operator to use for the comparison

Parameters

string $operator

The operator to be used for the comparison.

getOperator()

getOperator() : string

Returns the operator used for comparison

Returns

string

sql()

sql(\Cake\Database\ValueBinder  $generator) : string

Convert the expression into a SQL fragment.

Parameters

\Cake\Database\ValueBinder $generator

Placeholder generator object

Returns

string

traverse()

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

__clone()

__clone() : void

Create a deep clone.

Clones the field and value if they are expression objects.

setField()

setField(string|\Cake\Database\ExpressionInterface  $field) : void

Sets the field name

Parameters

string|\Cake\Database\ExpressionInterface $field

The field to compare with.

isMulti()

isMulti() : boolean

Determines if each of the values in this expressions is a tuple in itself

Returns

boolean

_stringExpression()

_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 —

First position containing the template and the second a placeholder

_bindValue()

_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 —

generated placeholder

_flattenValue()

_flattenValue(array|\Traversable  $value, \Cake\Database\ValueBinder  $generator, string|array|null  $type = 'string') : string

Converts a traversable value into a set of placeholders generated by $generator and separated by `,`

Parameters

array|\Traversable $value

the value to flatten

\Cake\Database\ValueBinder $generator

The value binder to use

string|array|null $type

the type to cast values to

Returns

string

_collectExpressions()

_collectExpressions(array|\Traversable  $values) : array

Returns an array with the original $values in the first position and all ExpressionInterface objects that could be found in the second position.

Parameters

array|\Traversable $values

The rows to insert

Returns

array

_castToExpression()

_castToExpression(mixed  $value, string  $type) : mixed

Conditionally converts the passed value to an ExpressionInterface object if the type class implements the ExpressionTypeInterface. Otherwise, returns the value unmodified.

Parameters

mixed $value

The value to converto to ExpressionInterface

string $type

The type name

Returns

mixed

_requiresToExpressionCasting()

_requiresToExpressionCasting(array  $types) : array

Returns an array with the types that require values to be casted to expressions, out of the list of type names passed as parameter.

Parameters

array $types

List of type names

Returns

array

_stringifyValues()

_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()

_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