W3cubDocs

/CakePHP 3.8

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

Cake\Database\Expression\Comparison implements Cake\Database\ExpressionInterface, Cake\Database\Expression\FieldInterface uses Cake\Database\Type\ExpressionTypeCasterTrait , Cake\Database\Expression\FieldTrait
Extended by Cake\Database\Expression\TupleComparison

Inherited Properties

Method Summary

  • __construct() public
    Constructor
  • _bindValue() protected

    Registers a value in the placeholder generator and returns the generated placeholder

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

  • isMulti() public

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

  • 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

__construct()source public

__construct( string|array|Cake\Database\ExpressionInterface $fields , array|Cake\Database\ExpressionInterface $values , array $types = [] , 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 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

Overrides

Cake\Database\Expression\Comparison::__construct()

_bindValue()source protected

_bindValue( Cake\Database\ValueBinder $generator , mixed $value , string $type )

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

Overrides

Cake\Database\Expression\Comparison::_bindValue()

_stringifyValues()source protected

_stringifyValues( Cake\Database\ValueBinder $generator )

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()source protected

_traverseValue( mixed $value , callable $callable )

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

isMulti()source public

isMulti( )

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

Returns

boolean

sql()source public

sql( Cake\Database\ValueBinder $generator )

Convert the expression into a SQL fragment.

Parameters

Cake\Database\ValueBinder $generator
Placeholder generator object

Returns

string

Overrides

Cake\Database\Expression\Comparison::sql()

traverse()source public

traverse( callable $callable )

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

Overrides

Cake\Database\Expression\Comparison::traverse()

Methods inherited from Cake\Database\Expression\Comparison

__clone()source public

__clone( )

Create a deep clone.

Clones the field and value if they are expression objects.

_collectExpressions()source protected

_collectExpressions( array|Traversable $values )

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

_flattenValue()source protected

_flattenValue( array|Traversable $value , Cake\Database\ValueBinder $generator , string|array|null $type = '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 optional 'string'
the type to cast values to

Returns

string

_stringExpression()source protected

_stringExpression( Cake\Database\ValueBinder $generator )

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

getOperator()source public

getOperator( )

Returns the operator used for comparison

Returns

string

getValue()source public

getValue( )

Returns the value used for comparison

Returns

mixed

setOperator()source public

setOperator( string $operator )

Sets the operator to use for the comparison

Parameters

string $operator
The operator to be used for the comparison.

setValue()source public

setValue( mixed $value )

Sets the value

Parameters

mixed $value
The value to compare

Methods used from Cake\Database\Type\ExpressionTypeCasterTrait

_castToExpression()source protected

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

Parameters

mixed $value
The value to converto to ExpressionInterface
string $type
The type name

Returns

mixed

_requiresToExpressionCasting()source protected

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

Parameters

array $types
List of type names

Returns

array

Methods used from Cake\Database\Expression\FieldTrait

getField()source public

getField( )

Returns the field name

Returns

string|Cake\Database\ExpressionInterface

setField()source public

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

Sets the field name

Parameters

string|Cake\Database\ExpressionInterface $field
The field to compare with.

© 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/3.8/class-Cake.Database.Expression.TupleComparison.html