Contains methods related to generating FunctionExpression objects with most commonly used SQL functions. This acts as a factory for FunctionExpression objects.
Magic method dispatcher to create custom SQL function calls
Helper method to create arbitrary SQL aggregate function calls.
Returns a AggregateExpression representing a call to SQL AVG function.
Returns a FunctionExpression representing a SQL CAST.
Returns a FunctionExpression representing a call to SQL COALESCE function.
Returns a FunctionExpression representing a string concatenation
Returns a AggregateExpression representing a call to SQL COUNT function.
Add the time unit to the date expression
Returns a FunctionExpression representing the difference in days between two dates.
Returns the specified date part from the SQL expression.
Returns a FunctionExpression representing a call to SQL WEEKDAY function. 1 - Sunday, 2 - Monday, 3 - Tuesday...
Returns the specified date part from the SQL expression.
Returns an AggregateExpression representing call to SQL LAG().
Returns an AggregateExpression representing call to SQL LEAD().
Returns a AggregateExpression representing a call to SQL MAX function.
Returns a AggregateExpression representing a call to SQL MIN function.
Returns a FunctionExpression representing a call that will return the current date and time. By default it returns both date and time, but you can also make it generate only the date or only the time.
Returns a FunctionExpression representing a call to SQL RAND function.
Returns an AggregateExpression representing call to SQL ROW_NUMBER().
Returns a AggregateExpression representing a call to SQL SUM function.
Creates function parameter array from expression or string literal.
Returns a FunctionExpression representing a call to SQL WEEKDAY function. 1 - Sunday, 2 - Monday, 3 - Tuesday...
__call(string $name, array $args): Cake\Database\Expression\FunctionExpression
Magic method dispatcher to create custom SQL function calls
string $name the SQL function name to construct
array $args list with up to 3 arguments, first one being an array with parameters for the SQL function, the second one a list of types to bind to those params, and the third one the return type of the function
Cake\Database\Expression\FunctionExpressionaggregate(string $name, array $params = [], array $types = [], string $return = 'float'): Cake\Database\Expression\AggregateExpression
Helper method to create arbitrary SQL aggregate function calls.
string $name The SQL aggregate function name
array $params optional Array of arguments to be passed to the function. Can be an associative array with the literal value or identifier: ['value' => 'literal'] or `['value' => 'identifier']
array $types optional Array of types that match the names used in $params: ['name' => 'type']
string $return optional Return type of the entire expression. Defaults to float.
Cake\Database\Expression\AggregateExpressionavg(Cake\Database\ExpressionInterface|string $expression, array $types = []): Cake\Database\Expression\AggregateExpression
Returns a AggregateExpression representing a call to SQL AVG function.
Cake\Database\ExpressionInterface|string $expression the function argument
array $types optional list of types to bind to the arguments
Cake\Database\Expression\AggregateExpressioncast(Cake\Database\ExpressionInterface|string $field, string $type = ''): Cake\Database\Expression\FunctionExpression
Returns a FunctionExpression representing a SQL CAST.
The $type parameter is a SQL type. The return type for the returned expression is the default type name. Use setReturnType() to update it.
Cake\Database\ExpressionInterface|string $field Field or expression to cast.
string $type optional The SQL data type
Cake\Database\Expression\FunctionExpressioncoalesce(array $args, array $types = []): Cake\Database\Expression\FunctionExpression
Returns a FunctionExpression representing a call to SQL COALESCE function.
array $args List of expressions to evaluate as function parameters
array $types optional list of types to bind to the arguments
Cake\Database\Expression\FunctionExpressionconcat(array $args, array $types = []): Cake\Database\Expression\FunctionExpression
Returns a FunctionExpression representing a string concatenation
array $args List of strings or expressions to concatenate
array $types optional list of types to bind to the arguments
Cake\Database\Expression\FunctionExpressioncount(Cake\Database\ExpressionInterface|string $expression, array $types = []): Cake\Database\Expression\AggregateExpression
Returns a AggregateExpression representing a call to SQL COUNT function.
Cake\Database\ExpressionInterface|string $expression the function argument
array $types optional list of types to bind to the arguments
Cake\Database\Expression\AggregateExpressiondateAdd(Cake\Database\ExpressionInterface|string $expression, string|int $value, string $unit, array $types = []): Cake\Database\Expression\FunctionExpression
Add the time unit to the date expression
Cake\Database\ExpressionInterface|string $expression Expression to obtain the date part from.
string|int $value Value to be added. Use negative to subtract.
string $unit Unit of the value e.g. hour or day.
array $types optional list of types to bind to the arguments
Cake\Database\Expression\FunctionExpressiondateDiff(array $args, array $types = []): Cake\Database\Expression\FunctionExpression
Returns a FunctionExpression representing the difference in days between two dates.
array $args List of expressions to obtain the difference in days.
array $types optional list of types to bind to the arguments
Cake\Database\Expression\FunctionExpressiondatePart(string $part, Cake\Database\ExpressionInterface|string $expression, array $types = []): Cake\Database\Expression\FunctionExpression
Returns the specified date part from the SQL expression.
string $part Part of the date to return.
Cake\Database\ExpressionInterface|string $expression Expression to obtain the date part from.
array $types optional list of types to bind to the arguments
Cake\Database\Expression\FunctionExpressiondayOfWeek(Cake\Database\ExpressionInterface|string $expression, array $types = []): Cake\Database\Expression\FunctionExpression
Returns a FunctionExpression representing a call to SQL WEEKDAY function. 1 - Sunday, 2 - Monday, 3 - Tuesday...
Cake\Database\ExpressionInterface|string $expression the function argument
array $types optional list of types to bind to the arguments
Cake\Database\Expression\FunctionExpressionextract(string $part, Cake\Database\ExpressionInterface|string $expression, array $types = []): Cake\Database\Expression\FunctionExpression
Returns the specified date part from the SQL expression.
string $part Part of the date to return.
Cake\Database\ExpressionInterface|string $expression Expression to obtain the date part from.
array $types optional list of types to bind to the arguments
Cake\Database\Expression\FunctionExpressionlag(Cake\Database\ExpressionInterface|string $expression, int $offset, mixed $default = null, string $type = null): Cake\Database\Expression\AggregateExpression
Returns an AggregateExpression representing call to SQL LAG().
Cake\Database\ExpressionInterface|string $expression The value evaluated at offset
int $offset The row offset
mixed $default optional The default value if offset doesn't exist
string $type optional The output type of the lag expression. Defaults to float.
Cake\Database\Expression\AggregateExpressionlead(Cake\Database\ExpressionInterface|string $expression, int $offset, mixed $default = null, string $type = null): Cake\Database\Expression\AggregateExpression
Returns an AggregateExpression representing call to SQL LEAD().
Cake\Database\ExpressionInterface|string $expression The value evaluated at offset
int $offset The row offset
mixed $default optional The default value if offset doesn't exist
string $type optional The output type of the lead expression. Defaults to float.
Cake\Database\Expression\AggregateExpressionmax(Cake\Database\ExpressionInterface|string $expression, array $types = []): Cake\Database\Expression\AggregateExpression
Returns a AggregateExpression representing a call to SQL MAX function.
Cake\Database\ExpressionInterface|string $expression the function argument
array $types optional list of types to bind to the arguments
Cake\Database\Expression\AggregateExpressionmin(Cake\Database\ExpressionInterface|string $expression, array $types = []): Cake\Database\Expression\AggregateExpression
Returns a AggregateExpression representing a call to SQL MIN function.
Cake\Database\ExpressionInterface|string $expression the function argument
array $types optional list of types to bind to the arguments
Cake\Database\Expression\AggregateExpressionnow(string $type = 'datetime'): Cake\Database\Expression\FunctionExpression
Returns a FunctionExpression representing a call that will return the current date and time. By default it returns both date and time, but you can also make it generate only the date or only the time.
string $type optional (datetime|date|time)
Cake\Database\Expression\FunctionExpressionrand(): Cake\Database\Expression\FunctionExpression
Returns a FunctionExpression representing a call to SQL RAND function.
Cake\Database\Expression\FunctionExpressionrowNumber(): Cake\Database\Expression\AggregateExpression
Returns an AggregateExpression representing call to SQL ROW_NUMBER().
Cake\Database\Expression\AggregateExpressionsum(Cake\Database\ExpressionInterface|string $expression, array $types = []): Cake\Database\Expression\AggregateExpression
Returns a AggregateExpression representing a call to SQL SUM function.
Cake\Database\ExpressionInterface|string $expression the function argument
array $types optional list of types to bind to the arguments
Cake\Database\Expression\AggregateExpressiontoLiteralParam(Cake\Database\ExpressionInterface|string $expression): arrayCake\Database\ExpressionInterface|string>
Creates function parameter array from expression or string literal.
Cake\Database\ExpressionInterface|string $expression function argument
arrayCake\Database\ExpressionInterface|string>weekday(Cake\Database\ExpressionInterface|string $expression, array $types = []): Cake\Database\Expression\FunctionExpression
Returns a FunctionExpression representing a call to SQL WEEKDAY function. 1 - Sunday, 2 - Monday, 3 - Tuesday...
Cake\Database\ExpressionInterface|string $expression the function argument
array $types optional list of types to bind to the arguments
Cake\Database\Expression\FunctionExpression
© 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.FunctionsBuilder.html