Fr3nch13/CakePHP Utilities

BetweenExpression
in package
implements ExpressionInterface, FieldInterface uses ExpressionTypeCasterTrait, FieldTrait

An expression object that represents a SQL BETWEEN snippet

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
$_from  : mixed
The first value in the expression
$_to  : mixed
The second value in the expression
$_type  : mixed
The data type for the from and to arguments

Methods

__clone()  : void
Do a deep clone of this expression.
__construct()  : mixed
Constructor
getField()  : ExpressionInterface|array<string|int, mixed>|string
Returns the field name
setField()  : void
Sets the field name
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.
_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.

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

Methods

__construct()

Constructor

public __construct(ExpressionInterface|string $field, mixed $from, mixed $to[, string|null $type = null ]) : mixed
Parameters
$field : ExpressionInterface|string

The field name to compare for values inbetween the range.

$from : mixed

The initial value of the range.

$to : mixed

The ending value in the comparison range.

$type : string|null = null

The data type name to bind the values with.

sql()

Converts the Node into a SQL string fragment.

public sql(ValueBinder $binder) : string
Parameters
$binder : ValueBinder

Parameter binder

Tags
inheritDoc
Return values
string

traverse()

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
inheritDoc
Return values
$this

_bindValue()

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

protected _bindValue(mixed $value, ValueBinder $binder, string $type) : string
Parameters
$value : mixed

The value to bind

$binder : ValueBinder

The value binder to use

$type : string

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

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

        
On this page

Search results