This represents a SQL window expression used by aggregate and window functions.
string
'FOLLOWING'
string
'GROUPS'
string
'PRECEDING'
string
'RANGE'
string
'ROWS'
string|null
array|null
\Cake\Database\Expression\IdentifierExpression
\Cake\Database\Expression\OrderByExpression|null
\Cake\Database\ExpressionInterface[]
Iterates over each part of the expression recursively for every level of the expressions tree and executes the $visitor callable passing as first parameter the instance of the expression currently being iterated.
__clone()
Clone this object and its subtree of expressions.
__construct(string $name)
string
$name optional Window name
buildOffsetSql(\Cake\Database\ValueBinder $generator, mixed $offset, string $direction)
Builds frame offset sql.
\Cake\Database\ValueBinder
$generator Value binder
int|string|\Cake\Database\ExpressionInterface|null
$offset Frame offset
string
$direction Frame offset direction
string
excludeCurrent()
Adds current row frame exclusion.
$this
excludeGroup()
Adds group frame exclusion.
$this
excludeTies()
Adds ties frame exclusion.
$this
frame(string $type, mixed $startOffset, string $startDirection, mixed $endOffset, string $endDirection)
Adds a frame to the window.
Use the range()
, rows()
or groups()
helpers if you need simple 'BETWEEN offset PRECEDING and offset FOLLOWING' frames.
You can specify any direction for both frame start and frame end.
With both $startOffset
and $endOffset
:
0
- 'CURRENT ROW'null
- 'UNBOUNDED'string
$type Frame type
int|string|\Cake\Database\ExpressionInterface|null
$startOffset Frame start offset
string
$startDirection Frame start direction
int|string|\Cake\Database\ExpressionInterface|null
$endOffset Frame end offset
string
$endDirection Frame end direction
$this
InvalidArgumentException
groups(?int $start, ?int $end)
Adds a simple groups frame to the window.
See range()
for details.
int|null
$start Frame start
int|null
$end optional Frame end If not passed in, only frame start SQL will be generated.
$this
isNamedOnly()
Return whether is only a named window expression.
These window expressions only specify a named window and do not specify their own partitions, frame or order.
bool
name(string $name)
Sets the window name.
string
$name Window name
$this
order(mixed $fields)
Adds one or more order clauses to the window.
\Closure|(\Cake\Database\ExpressionInterface|string)[]|\Cake\Database\ExpressionInterface|string
$fields Order expressions
$this
partition(mixed $partitions)
Adds one or more partition expressions to the window.
\Closure|(\Cake\Database\ExpressionInterface|string)[]|\Cake\Database\ExpressionInterface|string
$partitions Partition expressions
$this
range(mixed $start, mixed $end)
Adds a simple range frame to the window.
$start
:
0
- 'CURRENT ROW'null
- 'UNBOUNDED PRECEDING'$end
:
0
- 'CURRENT ROW'null
- 'UNBOUNDED FOLLOWING'If you need to use 'FOLLOWING' with frame start or 'PRECEDING' with frame end, use frame()
instead.
int|string|\Cake\Database\ExpressionInterface|null
$start Frame start
int|string|\Cake\Database\ExpressionInterface|null
$end optional Frame end If not passed in, only frame start SQL will be generated.
$this
rows(?int $start, ?int $end)
Adds a simple rows frame to the window.
See range()
for details.
int|null
$start Frame start
int|null
$end optional Frame end If not passed in, only frame start SQL will be generated.
$this
sql(\Cake\Database\ValueBinder $generator)
Converts the Node into a SQL string fragment.
\Cake\Database\ValueBinder
$generator Placeholder generator object
string
traverse(\Closure $visitor)
Iterates over each part of the expression recursively for every level of the expressions tree and executes the $visitor callable passing as first parameter the instance of the expression currently being iterated.
\Closure
$visitor The callable to apply to all nodes.
$this
string|null
array|null
\Cake\Database\Expression\IdentifierExpression
\Cake\Database\Expression\OrderByExpression|null
\Cake\Database\ExpressionInterface[]
© 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.1/class-Cake.Database.Expression.WindowExpression.html