CommonTableExpression
in package
implements
ExpressionInterface
An expression that represents a common table expression definition.
Table of Contents
Interfaces
- ExpressionInterface
- An interface used by Expression objects.
Properties
- $fields : array<string|int, IdentifierExpression>
- The field names to use for the CTE.
- $materialized : string|null
- Whether the CTE is materialized or not materialized.
- $name : IdentifierExpression
- The CTE name.
- $query : ExpressionInterface|null
- The CTE query definition.
- $recursive : bool
- Whether the CTE is recursive.
Methods
- __clone() : void
- Clones the inner expression objects.
- __construct() : mixed
- Constructor.
- field() : $this
- Adds one or more fields (arguments) to the CTE.
- isRecursive() : bool
- Gets whether this CTE is recursive.
- materialized() : $this
- Sets this CTE as materialized.
- name() : $this
- Sets the name of this CTE.
- notMaterialized() : $this
- Sets this CTE as not materialized.
- query() : $this
- Sets the query for this CTE.
- recursive() : $this
- Sets this CTE as recursive.
- 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.
Properties
$fields
The field names to use for the CTE.
protected
array<string|int, IdentifierExpression>
$fields
= []
$materialized
Whether the CTE is materialized or not materialized.
protected
string|null
$materialized
= null
$name
The CTE name.
protected
IdentifierExpression
$name
$query
The CTE query definition.
protected
ExpressionInterface|null
$query
$recursive
Whether the CTE is recursive.
protected
bool
$recursive
= false
Methods
__clone()
Clones the inner expression objects.
public
__clone() : void
__construct()
Constructor.
public
__construct([string $name = '' ][, ExpressionInterface|Closure $query = null ]) : mixed
Parameters
- $name : string = ''
-
The CTE name.
- $query : ExpressionInterface|Closure = null
-
CTE query
field()
Adds one or more fields (arguments) to the CTE.
public
field(IdentifierExpression|array<string|int, IdentifierExpression>|array<string|int, string>|string $fields) : $this
Parameters
- $fields : IdentifierExpression|array<string|int, IdentifierExpression>|array<string|int, string>|string
-
Field names
Return values
$thisisRecursive()
Gets whether this CTE is recursive.
public
isRecursive() : bool
Return values
boolmaterialized()
Sets this CTE as materialized.
public
materialized() : $this
Return values
$thisname()
Sets the name of this CTE.
public
name(string $name) : $this
This is the named you used to reference the expression in select, insert, etc queries.
Parameters
- $name : string
-
The CTE name.
Return values
$thisnotMaterialized()
Sets this CTE as not materialized.
public
notMaterialized() : $this
Return values
$thisquery()
Sets the query for this CTE.
public
query(ExpressionInterface|Closure $query) : $this
Parameters
- $query : ExpressionInterface|Closure
-
CTE query
Return values
$thisrecursive()
Sets this CTE as recursive.
public
recursive() : $this
Return values
$thissql()
Converts the Node into a SQL string fragment.
public
sql(ValueBinder $binder) : string
Parameters
- $binder : ValueBinder
-
Parameter binder
Tags
Return values
stringtraverse()
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.