CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 4.2 Strawberry API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 4.2
      • 5.2
      • 5.1
      • 5.0
      • 4.6
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Global
  • Cake
    • Auth
    • Cache
    • Collection
    • Command
    • Console
    • Controller
    • Core
    • Database
      • Driver
      • Exception
      • Expression
      • Log
      • Retry
      • Schema
      • Statement
      • Type
    • Datasource
    • Error
    • Event
    • Filesystem
    • Form
    • Http
    • I18n
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • Shell
    • TestSuite
    • Utility
    • Validation
    • View

Class WindowExpression

This represents a SQL window expression used by aggregate and window functions.

Namespace: Cake\Database\Expression

Constants

  • string
    FOLLOWING ¶
    'FOLLOWING'
  • string
    GROUPS ¶
    'GROUPS'
  • string
    PRECEDING ¶
    'PRECEDING'
  • string
    RANGE ¶
    'RANGE'
  • string
    ROWS ¶
    'ROWS'

Property Summary

  • $exclusion protected
    string|null
  • $frame protected
    array|null
  • $name protected
    Cake\Database\Expression\IdentifierExpression
  • $order protected
    Cake\Database\Expression\OrderByExpression|null
  • $partitions protected
    Cake\Database\ExpressionInterface[]

Method Summary

  • __clone() public

    Clone this object and its subtree of expressions.

  • __construct() public
  • buildOffsetSql() protected

    Builds frame offset sql.

  • excludeCurrent() public

    Adds current row frame exclusion.

  • excludeGroup() public

    Adds group frame exclusion.

  • excludeTies() public

    Adds ties frame exclusion.

  • frame() public

    Adds a frame to the window.

  • groups() public

    Adds a simple groups frame to the window.

  • isNamedOnly() public

    Return whether is only a named window expression.

  • name() public

    Sets the window name.

  • order() public

    Adds one or more order clauses to the window.

  • partition() public

    Adds one or more partition expressions to the window.

  • range() public

    Adds a simple range frame to the window.

  • rows() public

    Adds a simple rows frame to the window.

  • sql() public

    Converts the Node into a SQL string fragment.

  • traverse() public

    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.

Method Detail

__clone() ¶ public

__clone(): void

Clone this object and its subtree of expressions.

Returns
void

__construct() ¶ public

__construct(string $name = '')
Parameters
string $name optional

Window name

buildOffsetSql() ¶ protected

buildOffsetSql(Cake\Database\ValueBinder $binder, int|string|Cake\Database\ExpressionInterface|null $offset, string $direction): string

Builds frame offset sql.

Parameters
Cake\Database\ValueBinder $binder

Value binder

int|string|Cake\Database\ExpressionInterface|null $offset

Frame offset

string $direction

Frame offset direction

Returns
string

excludeCurrent() ¶ public

excludeCurrent(): $this

Adds current row frame exclusion.

Returns
$this

excludeGroup() ¶ public

excludeGroup(): $this

Adds group frame exclusion.

Returns
$this

excludeTies() ¶ public

excludeTies(): $this

Adds ties frame exclusion.

Returns
$this

frame() ¶ public

frame(string $type, int|string|Cake\Database\ExpressionInterface|null $startOffset, string $startDirection, int|string|Cake\Database\ExpressionInterface|null $endOffset, string $endDirection): $this

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'
Parameters
string $type
int|string|Cake\Database\ExpressionInterface|null $startOffset
string $startDirection
int|string|Cake\Database\ExpressionInterface|null $endOffset
string $endDirection
Returns
$this

groups() ¶ public

groups(int|null $start, int|null $end = 0): $this

Adds a simple groups frame to the window.

See range() for details.

Parameters
int|null $start
int|null $end optional
Returns
$this

isNamedOnly() ¶ public

isNamedOnly(): bool

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.

Returns
bool

name() ¶ public

name(string $name): $this

Sets the window name.

Parameters
string $name

Window name

Returns
$this

order() ¶ public

order(Closure|(Cake\Database\ExpressionInterface|string)[]|Cake\Database\ExpressionInterface|string $fields): $this

Adds one or more order clauses to the window.

Parameters
Closure|(Cake\Database\ExpressionInterface|string)[]|Cake\Database\ExpressionInterface|string $fields
Returns
$this

partition() ¶ public

partition(Closure|(Cake\Database\ExpressionInterface|string)[]|Cake\Database\ExpressionInterface|string $partitions): $this

Adds one or more partition expressions to the window.

Parameters
Closure|(Cake\Database\ExpressionInterface|string)[]|Cake\Database\ExpressionInterface|string $partitions
Returns
$this

range() ¶ public

range(int|string|Cake\Database\ExpressionInterface|null $start, int|string|Cake\Database\ExpressionInterface|null $end = 0): $this

Adds a simple range frame to the window.

$start:

  • 0 - 'CURRENT ROW'
  • null - 'UNBOUNDED PRECEDING'
  • offset - 'offset PRECEDING'

$end:

  • 0 - 'CURRENT ROW'
  • null - 'UNBOUNDED FOLLOWING'
  • offset - 'offset FOLLOWING'

If you need to use 'FOLLOWING' with frame start or 'PRECEDING' with frame end, use frame() instead.

Parameters
int|string|Cake\Database\ExpressionInterface|null $start
int|string|Cake\Database\ExpressionInterface|null $end optional
Returns
$this

rows() ¶ public

rows(int|null $start, int|null $end = 0): $this

Adds a simple rows frame to the window.

See range() for details.

Parameters
int|null $start
int|null $end optional
Returns
$this

sql() ¶ public

sql(Cake\Database\ValueBinder $binder): string

Converts the Node into a SQL string fragment.

Parameters
Cake\Database\ValueBinder $binder
Returns
string

traverse() ¶ public

traverse(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.

Parameters
Closure $callback
Returns
$this

Property Detail

$exclusion ¶ protected

Type
string|null

$frame ¶ protected

Type
array|null

$name ¶ protected

Type
Cake\Database\Expression\IdentifierExpression

$order ¶ protected

Type
Cake\Database\Expression\OrderByExpression|null

$partitions ¶ protected

Type
Cake\Database\ExpressionInterface[]
OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs