Represents a SQL when/then clause with a fluid API
Cake\Database\TypeMapThe type map to use when using an array of conditions for the WHEN value.
boolWhether the THEN value has been defined, eg whether then() has been invoked.
Cake\Database\ExpressionInterface|object|scalar|nullThe THEN value.
string|nullThe THEN result type.
array<string>The names of the clauses that are valid for use with the clause() method.
Cake\Database\ExpressionInterface|object|scalar|nullThen WHEN value.
array|string|nullThe WHEN value type.
Clones the inner expression objects.
Constructor.
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 types that require values to be casted to expressions, out of the list of type names passed as parameter.
Returns the available data for the given clause.
Compiles a nullable value to SQL.
Returns the expression's result value type.
Infers the abstract type for the given value.
Converts the Node into a SQL string fragment.
Sets the THEN result value.
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.
Sets the WHEN value.
__clone(): void
Clones the inner expression objects.
void__construct(Cake\Database\TypeMap|null $typeMap = null)
Constructor.
Cake\Database\TypeMap|null $typeMap optional The type map to use when using an array of conditions for the WHEN value.
_castToExpression(mixed $value, string|null $type = null): mixed
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 convert to ExpressionInterface
string|null $type optional The type name
mixed_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.
array $types List of type names
arrayclause(string $clause): Cake\Database\ExpressionInterface|object|scalar|null
Returns the available data for the given clause.
The following clause names are available:
when: The WHEN value.then: The THEN result value.string $clause The name of the clause to obtain.
Cake\Database\ExpressionInterface|object|scalar|nullInvalidArgumentExceptioncompileNullableValue(Cake\Database\ValueBinder $binder, Cake\Database\ExpressionInterface|object|scalar|null $value, string|null $type = null): string
Compiles a nullable value to SQL.
Cake\Database\ValueBinder $binder The value binder to use.
Cake\Database\ExpressionInterface|object|scalar|null $value The value to compile.
string|null $type optional The value type.
stringgetResultType(): string|null
Returns the expression's result value type.
string|nullinferType(mixed $value): string|null
Infers the abstract type for the given value.
mixed $value The value for which to infer the type.
string|nullsql(Cake\Database\ValueBinder $binder): string
Converts the Node into a SQL string fragment.
Cake\Database\ValueBinder $binder stringthen(Cake\Database\ExpressionInterface|object|scalar|null $result, string|null $type = null): $this
Sets the THEN result value.
Cake\Database\ExpressionInterface|object|scalar|null $result The result value.
string|null $type optional The result type. If no type is provided, the type will be inferred from the given result value.
$thistraverse(Closure $callback): $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.
Closure $callback $thiswhen(Cake\Database\ExpressionInterface|object|array|scalar $when, array<string, string>|string|null $type = null): $this
Sets the WHEN value.
Cake\Database\ExpressionInterface|object|array|scalar $when The WHEN value. When using an array of conditions, it must be compatible with \Cake\Database\Query::where(). Note that this argument is not completely safe for use with user data, as a user supplied array would allow for raw SQL to slip in! If you plan to use user data, either pass a single type for the $type argument (which forces the $when value to be a non-array, and then always binds the data), use a conditions array where the user data is only passed on the value side of the array entries, or custom bindings!
array<string, string>|string|null $type optional The when value type. Either an associative array when using array style conditions, or else a string. If no type is provided, the type will be tried to be inferred from the value.
$thisInvalidArgumentExceptionInvalidArgumentExceptionInvalidArgumentExceptionInvalidArgumentExceptionThe type map to use when using an array of conditions for the WHEN value.
Cake\Database\TypeMapWhether the THEN value has been defined, eg whether then() has been invoked.
boolThe THEN value.
Cake\Database\ExpressionInterface|object|scalar|nullThe THEN result type.
string|nullThe names of the clauses that are valid for use with the clause() method.
array<string>Then WHEN value.
Cake\Database\ExpressionInterface|object|scalar|nullThe WHEN value type.
array|string|null
© 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.4/class-Cake.Database.Expression.WhenThenExpression.html