With
extends Statement
in package
Class With.
Tags
Table of Contents
Constants
- OPT_RECURSIVE : string = 'RECURSIVE'
Properties
Methods
- __construct() : mixed
- Statement constructor.
- __toString() : string
- options() : static
- Sets the statement options.
- reference() : static
- Adds a table reference.
- reset() : static
- Resets SQL clauses and parts.
- run() : Result
- Runs the WITH statement.
- select() : static
- Sets the SELECT statement part.
- sql() : string
- Renders the WITH statement.
- hasOptions() : bool
- Tells if the statement has options set.
- renderAliasedIdentifier() : string
- Renders a column part with an optional alias name, AS clause.
- renderAssignment() : string
- Renders an assignment part.
- renderIdentifier() : string
- Renders a column part.
- renderLimit() : string|null
- Renders the LIMIT clause.
- renderOptions() : string|null
- renderReference() : string
- renderSelect() : string
- renderValue() : float|int|string
- Renders a subquery or quote a value.
- setLimit() : static
- Sets the LIMIT clause.
- subquery() : string
- Returns an SQL part between parentheses.
Constants
OPT_RECURSIVE
public
string
OPT_RECURSIVE
= 'RECURSIVE'
Tags
Properties
$database
protected
Database
$database
$sql
SQL clauses and parts.
protected
array<string, mixed>
$sql
= []
Methods
__construct()
Statement constructor.
public
__construct(Database $database) : mixed
Parameters
- $database : Database
__toString()
public
__toString() : string
Return values
stringoptions()
Sets the statement options.
public
options(string $option, string ...$options) : static
Parameters
- $option : string
-
One of the OPT_* constants
- $options : string
-
Each option value must be one of the OPT_* constants
Return values
staticreference()
Adds a table reference.
public
reference(Closure|string $table, Closure $alias) : static
Parameters
- $table : Closure|string
- $alias : Closure
Tags
Return values
staticreset()
Resets SQL clauses and parts.
public
reset([string|null $sql = null ]) : static
Parameters
- $sql : string|null = null
-
A part name or null to reset all
Tags
Return values
staticrun()
Runs the WITH statement.
public
run() : Result
Return values
Resultselect()
Sets the SELECT statement part.
public
select(Closure $select) : static
Parameters
- $select : Closure
Return values
staticsql()
Renders the WITH statement.
public
sql() : string
Return values
stringhasOptions()
Tells if the statement has options set.
protected
hasOptions() : bool
Return values
boolrenderAliasedIdentifier()
Renders a column part with an optional alias name, AS clause.
protected
renderAliasedIdentifier(Closure|array<string, Closure|string>|string $column) : string
Parameters
- $column : Closure|array<string, Closure|string>|string
-
The column name, a subquery or an array where the index is the alias and the value is the column/subquery
Return values
stringrenderAssignment()
Renders an assignment part.
protected
renderAssignment(string $identifier, Closure|float|int|string|null $expression) : string
Parameters
- $identifier : string
-
Identifier/column name
- $expression : Closure|float|int|string|null
-
Expression/value
Tags
Return values
stringrenderIdentifier()
Renders a column part.
protected
renderIdentifier(Closure|string $column) : string
Parameters
- $column : Closure|string
-
The column name or a subquery
Return values
stringrenderLimit()
Renders the LIMIT clause.
protected
renderLimit() : string|null
Return values
string|nullrenderOptions()
protected
renderOptions() : string|null
Return values
string|nullrenderReference()
protected
renderReference() : string
Return values
stringrenderSelect()
protected
renderSelect() : string
Return values
stringrenderValue()
Renders a subquery or quote a value.
protected
renderValue(Closure|float|int|string|null $value) : float|int|string
Parameters
- $value : Closure|float|int|string|null
-
A Closure for subquery, other types to quote
Return values
float|int|stringsetLimit()
Sets the LIMIT clause.
protected
setLimit(int $limit[, int|null $offset = null ]) : static
Parameters
- $limit : int
- $offset : int|null = null
Tags
Return values
staticsubquery()
Returns an SQL part between parentheses.
protected
subquery(Closure $subquery) : string
Parameters
- $subquery : Closure
-
A Closure having the current Manipulation instance as first argument. The returned value must be scalar