Aplus Framework Docs

Select extends Statement
in package
Uses Join, GroupBy, Having, OrderBy

Class Select.

Tags
see
https://mariadb.com/kb/en/select/

Table of Contents

EXP_FIELDS_ENCLOSED_BY  = 'ENCLOSED BY'
Clause to set the enclosure character of the fields. Default is ".
EXP_FIELDS_ESCAPED_BY  = 'ESCAPED BY'
EXP_FIELDS_OPTIONALLY_ENCLOSED_BY  = 'OPTIONALLY ENCLOSED BY'
EXP_FIELDS_TERMINATED_BY  = 'TERMINATED BY'
Clause to set the character of separation between fields. Default is \t.
EXP_LINES_STARTING_BY  = 'STARTING BY'
EXP_LINES_TERMINATED_BY  = 'TERMINATED BY'
Clause to set the file End-Of-Line character. Default is \n.
OPT_ALL  = 'ALL'
Option to retrieve identical rows.
OPT_DISTINCT  = 'DISTINCT'
Option to not retrieve identical rows. Remove duplicates from the result set.
OPT_DISTINCTROW  = 'DISTINCTROW'
Alias of OPT_DISTINCT.
OPT_HIGH_PRIORITY  = 'HIGH_PRIORITY'
If the table is locked, HIGH_PRIORITY will be executed as soon as the lock is released, even if other statements are queued.
OPT_SQL_BIG_RESULT  = 'SQL_BIG_RESULT'
Forces the optimizer to avoid usage of a temporary table.
OPT_SQL_BUFFER_RESULT  = 'SQL_BUFFER_RESULT'
Forces the optimizer to use a temporary table to process the result.
OPT_SQL_CACHE  = 'SQL_CACHE'
If the query_cache_type system variable is set to 2 or DEMAND, and the current statement is cacheable, SQL_CACHE causes the query to be cached.
OPT_SQL_CALC_FOUND_ROWS  = 'SQL_CALC_FOUND_ROWS'
SQL_CALC_FOUND_ROWS is only applied when using the LIMIT clause. If this option is used, MariaDB will count how many rows would match the query, without the LIMIT clause.
OPT_SQL_NO_CACHE  = 'SQL_NO_CACHE'
If the query_cache_type system variable is set to 2 or DEMAND, and the current statement is cacheable, SQL_NO_CACHE causes the query not to be cached.
OPT_SQL_SMALL_RESULT  = 'SQL_SMALL_RESULT'
Forces the optimizer to use a temporary table.
OPT_STRAIGHT_JOIN  = 'STRAIGHT_JOIN'
Applicable to the JOIN queries. Tells the optimizer that the tables must be read in the order they appear.
$database  : Database
$sql  : array<string|int, mixed>
SQL clauses and parts.
__construct()  : mixed
Statement constructor.
__toString()  : string
columns()  : static
Alias of the expressions method.
crossJoin()  : static
Adds a JOIN clause with "CROSS JOIN $table".
crossJoinOn()  : static
Adds a JOIN clause with "CROSS JOIN $table ON $conditional".
crossJoinUsing()  : static
Adds a JOIN clause with "CROSS JOIN $table USING ...$columns".
expressions()  : static
Set expressions.
from()  : static
Sets the FROM clause.
groupBy()  : static
Appends columns to the GROUP BY clause.
groupByAsc()  : static
Appends columns with the ASC direction to the GROUP BY clause.
groupByDesc()  : static
Appends columns with the DESC direction to the GROUP BY clause.
having()  : static
Appends an "AND $column $operator ...$values" condition in the HAVING clause.
havingBetween()  : static
Appends an "AND $column BETWEEN $min AND $max" condition in the HAVING clause.
havingEqual()  : static
Appends an "AND $column = $value" condition in the HAVING clause.
havingGreaterThan()  : static
Appends an "AND $column > $value" condition in the HAVING clause.
havingGreaterThanOrEqual()  : static
Appends an "AND $column >= $value" condition in the HAVING clause.
havingIn()  : static
Appends an "AND $column IN (...$values)" condition in the HAVING clause.
havingIsNotNull()  : static
Appends an "AND $column IS NOT NULL" condition in the HAVING clause.
havingIsNull()  : static
Appends an "AND $column IS NULL" condition in the HAVING clause.
havingLessThan()  : static
Appends an "AND $column < $value" condition in the HAVING clause.
havingLessThanOrEqual()  : static
Appends an "AND $column <= $value" condition in the HAVING clause.
havingLike()  : static
Appends an "AND $column LIKE $value" condition in the HAVING clause.
havingNotBetween()  : static
Appends an "AND $column NOT BETWEEN $min AND $max" condition in the HAVING clause.
havingNotEqual()  : static
Appends an "AND $column != $value" condition in the HAVING clause.
havingNotIn()  : static
Appends an "AND $column NOT IN (...$values)" condition in the HAVING clause.
havingNotLike()  : static
Appends an "AND $column NOT LIKE" $value condition.
havingNullSafeEqual()  : static
Appends an "AND $column <=> $value" condition in the HAVING clause.
innerJoinOn()  : static
Adds a JOIN clause with "INNER JOIN $table ON $conditional".
innerJoinUsing()  : static
Adds a JOIN clause with "INNER JOIN $table USING ...$columns".
intoDumpfile()  : static
intoOutfile()  : static
Exports the result to an external file.
join()  : static
Adds a JOIN clause with "$type JOIN $table $clause $conditional".
joinOn()  : static
Adds a JOIN clause with "JOIN $table ON $conditional".
joinUsing()  : static
Adds a JOIN clause with "JOIN $table USING ...$columns".
leftJoinOn()  : static
Adds a JOIN clause with "LEFT JOIN $table ON $conditional".
leftJoinUsing()  : static
Adds a JOIN clause with "LEFT JOIN $table USING ...$columns".
leftOuterJoinOn()  : static
Adds a JOIN clause with "LEFT OUTER JOIN $table ON $conditional".
leftOuterJoinUsing()  : static
Adds a JOIN clause with "LEFT OUTER JOIN $table USING ...$columns".
limit()  : static
Sets the LIMIT clause.
lockForUpdate()  : static
lockInShareMode()  : static
naturalJoin()  : static
Adds a JOIN clause with "NATURAL JOIN $table".
naturalLeftJoin()  : static
Adds a JOIN clause with "NATURAL LEFT JOIN $table".
naturalLeftOuterJoin()  : static
Adds a JOIN clause with "NATURAL LEFT OUTER JOIN $table".
naturalRightJoin()  : static
Adds a JOIN clause with "NATURAL RIGHT JOIN $table".
naturalRightOuterJoin()  : static
Adds a JOIN clause with "NATURAL RIGHT OUTER JOIN $table".
options()  : static
Sets the statement options.
orderBy()  : static
Appends columns to the ORDER BY clause.
orderByAsc()  : static
Appends columns with the ASC direction to the ORDER BY clause.
orderByDesc()  : static
Appends columns with the DESC direction to the ORDER BY clause.
orHaving()  : static
Appends a "OR $column $operator ...$values" condition in the HAVING clause.
orHavingBetween()  : static
Appends a "OR $column BETWEEN $min AND $max" condition in the HAVING clause.
orHavingEqual()  : static
Appends a "OR $column = $value" condition in the HAVING clause.
orHavingGreaterThan()  : static
Appends a "OR $column > $value" condition in the HAVING clause.
orHavingGreaterThanOrEqual()  : static
Appends a "OR $column >= $value" condition in the HAVING clause.
orHavingIn()  : static
Appends a "OR $column IN (...$values)" condition in the HAVING clause.
orHavingIsNotNull()  : static
Appends a "OR $column IS NOT NULL" condition in the HAVING clause.
orHavingIsNull()  : static
Appends a "OR $column IS NULL" condition in the HAVING clause.
orHavingLessThan()  : static
Appends a "OR $column < $value" condition in the HAVING clause.
orHavingLessThanOrEqual()  : static
Appends a "OR $column <= $value" condition in the HAVING clause.
orHavingLike()  : static
Appends a "OR $column LIKE $value" condition in the HAVING clause.
orHavingNotBetween()  : static
Appends a "OR $column NOT BETWEEN $min AND $max" condition in the HAVING clause.
orHavingNotEqual()  : static
Appends a "OR $column != $value" condition in the HAVING clause.
orHavingNotIn()  : static
Appends a "OR $column NOT IN (...$values)" condition in the HAVING clause.
orHavingNotLike()  : static
Appends a "OR $column NOT LIKE $value" condition in the HAVING clause.
orHavingNullSafeEqual()  : static
Appends a "OR $column <=> $value" condition in the HAVING clause.
procedure()  : static
reset()  : static
Resets SQL clauses and parts.
rightJoinOn()  : static
Adds a JOIN clause with "RIGHT JOIN $table ON $conditional".
rightJoinUsing()  : static
Adds a JOIN clause with "RIGHT JOIN $table USING ...$columns".
rightOuterJoinOn()  : static
Adds a JOIN clause with "RIGHT OUTER JOIN $table ON $conditional".
rightOuterJoinUsing()  : static
Adds a JOIN clause with "RIGHT OUTER JOIN $table USING ...$columns".
run()  : Result
Runs the SELECT statement.
runUnbuffered()  : Result
Runs the SELECT statement unbuffered.
sql()  : string
Renders the SELECT statement.
hasFrom()  : bool
Tells if the FROM clause was set.
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.
renderExpressions()  : string|null
renderFrom()  : string|null
Renders the FROM clause.
renderGroupBy()  : string|null
Renders the GROUP BY clause.
renderHaving()  : string|null
Renders the full HAVING clause.
renderIdentifier()  : string
Renders a column part.
renderIntoDumpfile()  : string|null
renderIntoOutfile()  : string|null
renderJoin()  : string|null
Renders the JOIN clause.
renderLimit()  : string|null
Renders the LIMIT clause.
renderLock()  : string|null
renderOptions()  : string|null
renderOrderBy()  : string|null
Renders the ORDER BY clause.
renderProcedure()  : string|null
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

EXP_FIELDS_ENCLOSED_BY

Clause to set the enclosure character of the fields. Default is ".

public string EXP_FIELDS_ENCLOSED_BY = 'ENCLOSED BY'
Tags
see
Select::intoOutfile()

EXP_FIELDS_OPTIONALLY_ENCLOSED_BY

public string EXP_FIELDS_OPTIONALLY_ENCLOSED_BY = 'OPTIONALLY ENCLOSED BY'
Tags
see
Select::intoOutfile()

EXP_FIELDS_TERMINATED_BY

Clause to set the character of separation between fields. Default is \t.

public string EXP_FIELDS_TERMINATED_BY = 'TERMINATED BY'
Tags
see
Select::intoOutfile()

EXP_LINES_TERMINATED_BY

Clause to set the file End-Of-Line character. Default is \n.

public string EXP_LINES_TERMINATED_BY = 'TERMINATED BY'
Tags
see
Select::intoOutfile()

OPT_SQL_CALC_FOUND_ROWS

SQL_CALC_FOUND_ROWS is only applied when using the LIMIT clause. If this option is used, MariaDB will count how many rows would match the query, without the LIMIT clause.

public string OPT_SQL_CALC_FOUND_ROWS = 'SQL_CALC_FOUND_ROWS'

That number can be retrieved in the next query, using FOUND_ROWS().

Tags
see
Select::renderOptions()
see
https://mariadb.com/kb/en/found_rows/

Properties

$sql

SQL clauses and parts.

protected array<string|int, mixed> $sql = []

Methods

__construct()

Statement constructor.

public __construct(Database $database) : mixed
Parameters
$database : Database
Return values
mixed

__toString()

public __toString() : string
Return values
string

columns()

Alias of the expressions method.

public columns(array<string, \Closure|string>|Closure|string $expression, array<string, \Closure|string>|Closure|string ...$expressions) : static
Parameters
$expression : array<string, \Closure|string>|Closure|string
$expressions : array<string, \Closure|string>|Closure|string
Return values
static

crossJoin()

Adds a JOIN clause with "CROSS JOIN $table".

public crossJoin(array<string, \Closure|string>|Closure|string $table) : static
Parameters
$table : array<string, \Closure|string>|Closure|string

Table factor

Return values
static

crossJoinOn()

Adds a JOIN clause with "CROSS JOIN $table ON $conditional".

public crossJoinOn(array<string, \Closure|string>|Closure|string $table, Closure $conditional) : static
Parameters
$table : array<string, \Closure|string>|Closure|string

Table factor

$conditional : Closure

Conditional expression

Return values
static

crossJoinUsing()

Adds a JOIN clause with "CROSS JOIN $table USING ...$columns".

public crossJoinUsing(array<string, \Closure|string>|Closure|string $table, Closure|string ...$columns) : static
Parameters
$table : array<string, \Closure|string>|Closure|string

Table factor

$columns : Closure|string

Columns list

Return values
static

expressions()

Set expressions.

public expressions(array<string, \Closure|string>|Closure|string $expression, array<string, \Closure|string>|Closure|string ...$expressions) : static

Generally used with the FROM clause as column names.

Parameters
$expression : array<string, \Closure|string>|Closure|string
$expressions : array<string, \Closure|string>|Closure|string
Tags
see
https://mariadb.com/kb/en/select/#select-expressions
Return values
static

from()

Sets the FROM clause.

public from(array<string, \Closure|string>|Closure|string $reference, array<string, \Closure|string>|Closure|string ...$references) : static
Parameters
$reference : array<string, \Closure|string>|Closure|string

Table reference

$references : array<string, \Closure|string>|Closure|string

Table references

Tags
see
https://mariadb.com/kb/en/join-syntax/
Return values
static

groupBy()

Appends columns to the GROUP BY clause.

public groupBy(Closure|string $column, Closure|string ...$columns) : static
Parameters
$column : Closure|string

The column name or a subquery

$columns : Closure|string

Extra column names and/or subqueries

Return values
static

groupByAsc()

Appends columns with the ASC direction to the GROUP BY clause.

public groupByAsc(Closure|string $column, Closure|string ...$columns) : static
Parameters
$column : Closure|string

The column name or a subquery

$columns : Closure|string

Extra column names and/or subqueries

Return values
static

groupByDesc()

Appends columns with the DESC direction to the GROUP BY clause.

public groupByDesc(Closure|string $column, Closure|string ...$columns) : static
Parameters
$column : Closure|string

The column name or a subquery

$columns : Closure|string

Extra column names and/or subqueries

Return values
static

having()

Appends an "AND $column $operator ...$values" condition in the HAVING clause.

public having(Closure|string $column, string $operator, Closure|float|int|string|null ...$values) : static
Parameters
$column : Closure|string

Closure for a subquery or a string with the column name

$operator : string
$values : Closure|float|int|string|null
Return values
static

havingBetween()

Appends an "AND $column BETWEEN $min AND $max" condition in the HAVING clause.

public havingBetween(Closure|string $column, Closure|float|int|string|null $min, Closure|float|int|string|null $max) : static
Parameters
$column : Closure|string

Closure for a subquery or a string with the column name

$min : Closure|float|int|string|null
$max : Closure|float|int|string|null
Tags
see
https://mariadb.com/kb/en/between-and/
Return values
static

havingEqual()

Appends an "AND $column = $value" condition in the HAVING clause.

public havingEqual(Closure|string $column, Closure|float|int|string|null $value) : static
Parameters
$column : Closure|string

Closure for a subquery or a string with the column name

$value : Closure|float|int|string|null
Tags
see
https://mariadb.com/kb/en/equal/
Return values
static

havingGreaterThan()

Appends an "AND $column > $value" condition in the HAVING clause.

public havingGreaterThan(Closure|string $column, Closure|float|int|string|null $value) : static
Parameters
$column : Closure|string

Closure for a subquery or a string with the column name

$value : Closure|float|int|string|null
Tags
see
https://mariadb.com/kb/en/greater-than/
Return values
static

havingGreaterThanOrEqual()

Appends an "AND $column >= $value" condition in the HAVING clause.

public havingGreaterThanOrEqual(Closure|string $column, Closure|float|int|string|null $value) : static
Parameters
$column : Closure|string

Closure for a subquery or a string with the column name

$value : Closure|float|int|string|null
Tags
see
https://mariadb.com/kb/en/greater-than-or-equal/
Return values
static

havingIn()

Appends an "AND $column IN (...$values)" condition in the HAVING clause.

public havingIn(Closure|string $column, Closure|float|int|string|null $value, Closure|float|int|string|null ...$values) : static
Parameters
$column : Closure|string

Closure for a subquery or a string with the column name

$value : Closure|float|int|string|null
$values : Closure|float|int|string|null
Tags
see
https://mariadb.com/kb/en/in/
Return values
static

havingIsNotNull()

Appends an "AND $column IS NOT NULL" condition in the HAVING clause.

public havingIsNotNull(Closure|string $column) : static
Parameters
$column : Closure|string

Closure for a subquery or a string with the column name

Tags
see
https://mariadb.com/kb/en/is-not-null/
Return values
static

havingIsNull()

Appends an "AND $column IS NULL" condition in the HAVING clause.

public havingIsNull(Closure|string $column) : static
Parameters
$column : Closure|string

Closure for a subquery or a string with the column name

Tags
see
https://mariadb.com/kb/en/is-null/
Return values
static

havingLessThan()

Appends an "AND $column < $value" condition in the HAVING clause.

public havingLessThan(Closure|string $column, Closure|float|int|string|null $value) : static
Parameters
$column : Closure|string

Closure for a subquery or a string with the column name

$value : Closure|float|int|string|null
Tags
see
https://mariadb.com/kb/en/less-than/
Return values
static

havingLessThanOrEqual()

Appends an "AND $column <= $value" condition in the HAVING clause.

public havingLessThanOrEqual(Closure|string $column, Closure|float|int|string|null $value) : static
Parameters
$column : Closure|string

Closure for a subquery or a string with the column name

$value : Closure|float|int|string|null
Tags
see
https://mariadb.com/kb/en/less-than-or-equal/
Return values
static

havingLike()

Appends an "AND $column LIKE $value" condition in the HAVING clause.

public havingLike(Closure|string $column, Closure|float|int|string|null $value) : static
Parameters
$column : Closure|string

Closure for a subquery or a string with the column name

$value : Closure|float|int|string|null
Tags
see
https://mariadb.com/kb/en/like/
Return values
static

havingNotBetween()

Appends an "AND $column NOT BETWEEN $min AND $max" condition in the HAVING clause.

public havingNotBetween(Closure|string $column, Closure|float|int|string|null $min, Closure|float|int|string|null $max) : static
Parameters
$column : Closure|string

Closure for a subquery or a string with the column name

$min : Closure|float|int|string|null
$max : Closure|float|int|string|null
Tags
see
https://mariadb.com/kb/en/not-between/
Return values
static

havingNotEqual()

Appends an "AND $column != $value" condition in the HAVING clause.

public havingNotEqual(Closure|string $column, Closure|float|int|string|null $value) : static
Parameters
$column : Closure|string

Closure for a subquery or a string with the column name

$value : Closure|float|int|string|null
Tags
see
https://mariadb.com/kb/en/not-equal/
Return values
static

havingNotIn()

Appends an "AND $column NOT IN (...$values)" condition in the HAVING clause.

public havingNotIn(Closure|string $column, Closure|float|int|string|null $value, Closure|float|int|string|null ...$values) : static
Parameters
$column : Closure|string

Closure for a subquery or a string with the column name

$value : Closure|float|int|string|null
$values : Closure|float|int|string|null
Tags
see
https://mariadb.com/kb/en/not-in/
Return values
static

havingNotLike()

Appends an "AND $column NOT LIKE" $value condition.

public havingNotLike(Closure|string $column, Closure|float|int|string|null $value) : static
Parameters
$column : Closure|string

Closure for a subquery or a string with the column name

$value : Closure|float|int|string|null
Tags
see
https://mariadb.com/kb/en/not-like/
Return values
static

havingNullSafeEqual()

Appends an "AND $column <=> $value" condition in the HAVING clause.

public havingNullSafeEqual(Closure|string $column, Closure|float|int|string|null $value) : static
Parameters
$column : Closure|string

Closure for a subquery or a string with the column name

$value : Closure|float|int|string|null
Tags
see
https://mariadb.com/kb/en/null-safe-equal/
Return values
static

innerJoinOn()

Adds a JOIN clause with "INNER JOIN $table ON $conditional".

public innerJoinOn(array<string, \Closure|string>|Closure|string $table, Closure $conditional) : static
Parameters
$table : array<string, \Closure|string>|Closure|string

Table factor

$conditional : Closure

Conditional expression

Return values
static

innerJoinUsing()

Adds a JOIN clause with "INNER JOIN $table USING ...$columns".

public innerJoinUsing(array<string, \Closure|string>|Closure|string $table, Closure|string ...$columns) : static
Parameters
$table : array<string, \Closure|string>|Closure|string

Table factor

$columns : Closure|string

Columns list

Return values
static

intoOutfile()

Exports the result to an external file.

public intoOutfile(string $filename[, string|null $charset = null ][, array<string, string> $fieldsOptions = [] ][, array<string, string> $linesOptions = [] ]) : static
Parameters
$filename : string
$charset : string|null = null
$fieldsOptions : array<string, string> = []

Each key must be one of the EXP_FIELDS_* constants

$linesOptions : array<string, string> = []

Each key must be one of the EXP_LINES_* constants

Tags
see
https://mariadb.com/kb/en/select-into-outfile/
Return values
static

join()

Adds a JOIN clause with "$type JOIN $table $clause $conditional".

public join(array<string, \Closure|string>|Closure|string $table[, string $type = '' ][, string|null $clause = null ][, array<int, \Closure|string>|Closure|null $conditional = null ]) : static
Parameters
$table : array<string, \Closure|string>|Closure|string

Table factor

$type : string = ''

JOIN type. One of: CROSS, INNER, LEFT, LEFT OUTER, RIGHT, RIGHT OUTER, NATURAL, NATURAL LEFT, NATURAL LEFT OUTER, NATURAL RIGHT, NATURAL RIGHT OUTER or empty (same as INNER)

$clause : string|null = null

Condition clause. Null if it has a NATURAL type, otherwise ON or USING

$conditional : array<int, \Closure|string>|Closure|null = null

A conditional expression as Closure or the columns list as array

Return values
static

joinOn()

Adds a JOIN clause with "JOIN $table ON $conditional".

public joinOn(array<string, \Closure|string>|Closure|string $table, Closure $conditional) : static
Parameters
$table : array<string, \Closure|string>|Closure|string

Table factor

$conditional : Closure

Conditional expression

Return values
static

joinUsing()

Adds a JOIN clause with "JOIN $table USING ...$columns".

public joinUsing(array<string, \Closure|string>|Closure|string $table, Closure|string ...$columns) : static
Parameters
$table : array<string, \Closure|string>|Closure|string

Table factor

$columns : Closure|string

Columns list

Return values
static

leftJoinOn()

Adds a JOIN clause with "LEFT JOIN $table ON $conditional".

public leftJoinOn(array<string, \Closure|string>|Closure|string $table, Closure $conditional) : static
Parameters
$table : array<string, \Closure|string>|Closure|string

Table factor

$conditional : Closure

Conditional expression

Return values
static

leftJoinUsing()

Adds a JOIN clause with "LEFT JOIN $table USING ...$columns".

public leftJoinUsing(array<string, \Closure|string>|Closure|string $table, Closure|string ...$columns) : static
Parameters
$table : array<string, \Closure|string>|Closure|string

Table factor

$columns : Closure|string

Columns list

Return values
static

leftOuterJoinOn()

Adds a JOIN clause with "LEFT OUTER JOIN $table ON $conditional".

public leftOuterJoinOn(array<string, \Closure|string>|Closure|string $table, Closure $conditional) : static
Parameters
$table : array<string, \Closure|string>|Closure|string

Table factor

$conditional : Closure

Conditional expression

Return values
static

leftOuterJoinUsing()

Adds a JOIN clause with "LEFT OUTER JOIN $table USING ...$columns".

public leftOuterJoinUsing(array<string, \Closure|string>|Closure|string $table, Closure|string ...$columns) : static
Parameters
$table : array<string, \Closure|string>|Closure|string

Table factor

$columns : Closure|string

Columns list

Return values
static

limit()

Sets the LIMIT clause.

public limit(int $limit[, int|null $offset = null ]) : static
Parameters
$limit : int
$offset : int|null = null
Tags
see
https://mariadb.com/kb/en/limit/
Return values
static

naturalJoin()

Adds a JOIN clause with "NATURAL JOIN $table".

public naturalJoin(array<string, \Closure|string>|Closure|string $table) : static
Parameters
$table : array<string, \Closure|string>|Closure|string

Table factor

Return values
static

naturalLeftJoin()

Adds a JOIN clause with "NATURAL LEFT JOIN $table".

public naturalLeftJoin(array<string, \Closure|string>|Closure|string $table) : static
Parameters
$table : array<string, \Closure|string>|Closure|string

Table factor

Return values
static

naturalLeftOuterJoin()

Adds a JOIN clause with "NATURAL LEFT OUTER JOIN $table".

public naturalLeftOuterJoin(array<string, \Closure|string>|Closure|string $table) : static
Parameters
$table : array<string, \Closure|string>|Closure|string

Table factor

Return values
static

naturalRightJoin()

Adds a JOIN clause with "NATURAL RIGHT JOIN $table".

public naturalRightJoin(array<string, \Closure|string>|Closure|string $table) : static
Parameters
$table : array<string, \Closure|string>|Closure|string

Table factor

Return values
static

naturalRightOuterJoin()

Adds a JOIN clause with "NATURAL RIGHT OUTER JOIN $table".

public naturalRightOuterJoin(array<string, \Closure|string>|Closure|string $table) : static
Parameters
$table : array<string, \Closure|string>|Closure|string

Table factor

Return values
static

options()

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
static

orderBy()

Appends columns to the ORDER BY clause.

public orderBy(Closure|string $column, Closure|string ...$columns) : static
Parameters
$column : Closure|string

The column name or a subquery

$columns : Closure|string

Extra column names and/or subqueries

Return values
static

orderByAsc()

Appends columns with the ASC direction to the ORDER BY clause.

public orderByAsc(Closure|string $column, Closure|string ...$columns) : static
Parameters
$column : Closure|string

The column name or a subquery

$columns : Closure|string

Extra column names and/or subqueries

Return values
static

orderByDesc()

Appends columns with the DESC direction to the ORDER BY clause.

public orderByDesc(Closure|string $column, Closure|string ...$columns) : static
Parameters
$column : Closure|string

The column name or a subquery

$columns : Closure|string

Extra column names and/or subqueries

Return values
static

orHaving()

Appends a "OR $column $operator ...$values" condition in the HAVING clause.

public orHaving(Closure|string $column, string $operator, Closure|float|int|string|null ...$values) : static
Parameters
$column : Closure|string

Closure for a subquery or a string with the column name

$operator : string
$values : Closure|float|int|string|null
Return values
static

orHavingBetween()

Appends a "OR $column BETWEEN $min AND $max" condition in the HAVING clause.

public orHavingBetween(Closure|string $column, Closure|float|int|string|null $min, Closure|float|int|string|null $max) : static
Parameters
$column : Closure|string

Closure for a subquery or a string with the column name

$min : Closure|float|int|string|null
$max : Closure|float|int|string|null
Tags
see
https://mariadb.com/kb/en/between-and/
Return values
static

orHavingEqual()

Appends a "OR $column = $value" condition in the HAVING clause.

public orHavingEqual(Closure|string $column, Closure|float|int|string|null $value) : static
Parameters
$column : Closure|string

Closure for a subquery or a string with the column name

$value : Closure|float|int|string|null
Tags
see
https://mariadb.com/kb/en/equal/
Return values
static

orHavingGreaterThan()

Appends a "OR $column > $value" condition in the HAVING clause.

public orHavingGreaterThan(Closure|string $column, Closure|float|int|string|null $value) : static
Parameters
$column : Closure|string

Closure for a subquery or a string with the column name

$value : Closure|float|int|string|null
Tags
see
https://mariadb.com/kb/en/greater-than/
Return values
static

orHavingGreaterThanOrEqual()

Appends a "OR $column >= $value" condition in the HAVING clause.

public orHavingGreaterThanOrEqual(Closure|string $column, Closure|float|int|string|null $value) : static
Parameters
$column : Closure|string

Closure for a subquery or a string with the column name

$value : Closure|float|int|string|null
Tags
see
https://mariadb.com/kb/en/greater-than-or-equal/
Return values
static

orHavingIn()

Appends a "OR $column IN (...$values)" condition in the HAVING clause.

public orHavingIn(Closure|string $column, Closure|float|int|string|null $value, Closure|float|int|string|null ...$values) : static
Parameters
$column : Closure|string

Closure for a subquery or a string with the column name

$value : Closure|float|int|string|null
$values : Closure|float|int|string|null
Tags
see
https://mariadb.com/kb/en/in/
Return values
static

orHavingIsNotNull()

Appends a "OR $column IS NOT NULL" condition in the HAVING clause.

public orHavingIsNotNull(Closure|string $column) : static
Parameters
$column : Closure|string

Closure for a subquery or a string with the column name

Tags
see
https://mariadb.com/kb/en/is-not-null/
Return values
static

orHavingIsNull()

Appends a "OR $column IS NULL" condition in the HAVING clause.

public orHavingIsNull(Closure|string $column) : static
Parameters
$column : Closure|string

Closure for a subquery or a string with the column name

Tags
see
https://mariadb.com/kb/en/is-null/
Return values
static

orHavingLessThan()

Appends a "OR $column < $value" condition in the HAVING clause.

public orHavingLessThan(Closure|string $column, Closure|float|int|string|null $value) : static
Parameters
$column : Closure|string

Closure for a subquery or a string with the column name

$value : Closure|float|int|string|null
Tags
see
https://mariadb.com/kb/en/less-than/
Return values
static

orHavingLessThanOrEqual()

Appends a "OR $column <= $value" condition in the HAVING clause.

public orHavingLessThanOrEqual(Closure|string $column, Closure|float|int|string|null $value) : static
Parameters
$column : Closure|string

Closure for a subquery or a string with the column name

$value : Closure|float|int|string|null
Tags
see
https://mariadb.com/kb/en/less-than-or-equal/
Return values
static

orHavingLike()

Appends a "OR $column LIKE $value" condition in the HAVING clause.

public orHavingLike(Closure|string $column, Closure|float|int|string|null $value) : static
Parameters
$column : Closure|string

Closure for a subquery or a string with the column name

$value : Closure|float|int|string|null
Tags
see
https://mariadb.com/kb/en/like/
Return values
static

orHavingNotBetween()

Appends a "OR $column NOT BETWEEN $min AND $max" condition in the HAVING clause.

public orHavingNotBetween(Closure|string $column, Closure|float|int|string|null $min, Closure|float|int|string|null $max) : static
Parameters
$column : Closure|string

Closure for a subquery or a string with the column name

$min : Closure|float|int|string|null
$max : Closure|float|int|string|null
Tags
see
https://mariadb.com/kb/en/not-between/
Return values
static

orHavingNotEqual()

Appends a "OR $column != $value" condition in the HAVING clause.

public orHavingNotEqual(Closure|string $column, Closure|float|int|string|null $value) : static
Parameters
$column : Closure|string

Closure for a subquery or a string with the column name

$value : Closure|float|int|string|null
Tags
see
https://mariadb.com/kb/en/not-equal/
Return values
static

orHavingNotIn()

Appends a "OR $column NOT IN (...$values)" condition in the HAVING clause.

public orHavingNotIn(Closure|string $column, Closure|float|int|string|null $value, Closure|float|int|string|null ...$values) : static
Parameters
$column : Closure|string

Closure for a subquery or a string with the column name

$value : Closure|float|int|string|null
$values : Closure|float|int|string|null
Tags
see
https://mariadb.com/kb/en/not-in/
Return values
static

orHavingNotLike()

Appends a "OR $column NOT LIKE $value" condition in the HAVING clause.

public orHavingNotLike(Closure|string $column, Closure|float|int|string|null $value) : static
Parameters
$column : Closure|string

Closure for a subquery or a string with the column name

$value : Closure|float|int|string|null
Tags
see
https://mariadb.com/kb/en/not-like/
Return values
static

orHavingNullSafeEqual()

Appends a "OR $column <=> $value" condition in the HAVING clause.

public orHavingNullSafeEqual(Closure|string $column, Closure|float|int|string|null $value) : static
Parameters
$column : Closure|string

Closure for a subquery or a string with the column name

$value : Closure|float|int|string|null
Tags
see
https://mariadb.com/kb/en/null-safe-equal/
Return values
static

procedure()

public procedure(string $name, bool|float|int|string|null ...$arguments) : static
Parameters
$name : string
$arguments : bool|float|int|string|null
Tags
see
https://mariadb.com/kb/en/procedure/
Return values
static

reset()

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
see
Statement::$sql
Return values
static

rightJoinOn()

Adds a JOIN clause with "RIGHT JOIN $table ON $conditional".

public rightJoinOn(array<string, \Closure|string>|Closure|string $table, Closure $conditional) : static
Parameters
$table : array<string, \Closure|string>|Closure|string

Table factor

$conditional : Closure

Conditional expression

Return values
static

rightJoinUsing()

Adds a JOIN clause with "RIGHT JOIN $table USING ...$columns".

public rightJoinUsing(array<string, \Closure|string>|Closure|string $table, Closure|string ...$columns) : static
Parameters
$table : array<string, \Closure|string>|Closure|string

Table factor

$columns : Closure|string

Columns list

Return values
static

rightOuterJoinOn()

Adds a JOIN clause with "RIGHT OUTER JOIN $table ON $conditional".

public rightOuterJoinOn(array<string, \Closure|string>|Closure|string $table, Closure $conditional) : static
Parameters
$table : array<string, \Closure|string>|Closure|string

Table factor

$conditional : Closure

Conditional expression

Return values
static

rightOuterJoinUsing()

Adds a JOIN clause with "RIGHT OUTER JOIN $table USING ...$columns".

public rightOuterJoinUsing(array<string, \Closure|string>|Closure|string $table, Closure|string ...$columns) : static
Parameters
$table : array<string, \Closure|string>|Closure|string

Table factor

$columns : Closure|string

Columns list

Return values
static

runUnbuffered()

Runs the SELECT statement unbuffered.

public runUnbuffered() : Result
Return values
Result

sql()

Renders the SELECT statement.

public sql() : string
Return values
string

hasFrom()

Tells if the FROM clause was set.

protected hasFrom([string|null $clause = null ]) : bool
Parameters
$clause : string|null = null

A clause where FROM is required

Tags
throws
LogicException

if FROM is not set, but is required for some other clause

Return values
bool

True if it has FROM, otherwise false

hasOptions()

Tells if the statement has options set.

protected hasOptions() : bool
Return values
bool

renderAliasedIdentifier()

Renders a column part with an optional alias name, AS clause.

protected renderAliasedIdentifier(array<string, \Closure|string>|Closure|string $column) : string
Parameters
$column : array<string, \Closure|string>|Closure|string

The column name, a subquery or an array where the index is the alias and the value is the column/subquery

Return values
string

renderExpressions()

protected renderExpressions() : string|null
Return values
string|null

renderFrom()

Renders the FROM clause.

protected renderFrom() : string|null
Return values
string|null

The FROM clause or null if it was not set

renderGroupBy()

Renders the GROUP BY clause.

protected renderGroupBy() : string|null
Return values
string|null

The GROUP BY clause or null if it was not set

renderHaving()

Renders the full HAVING clause.

protected renderHaving() : string|null
Return values
string|null

The full clause or null if has not a clause

renderIdentifier()

Renders a column part.

protected renderIdentifier(Closure|string $column) : string
Parameters
$column : Closure|string

The column name or a subquery

Return values
string

renderIntoDumpfile()

protected renderIntoDumpfile() : string|null
Return values
string|null

renderIntoOutfile()

protected renderIntoOutfile() : string|null
Return values
string|null

renderJoin()

Renders the JOIN clause.

protected renderJoin() : string|null
Return values
string|null

The JOIN clause or null if it was not set

renderLimit()

Renders the LIMIT clause.

protected renderLimit() : string|null
Return values
string|null

renderLock()

protected renderLock() : string|null
Return values
string|null

renderOptions()

protected renderOptions() : string|null
Return values
string|null

renderOrderBy()

Renders the ORDER BY clause.

protected renderOrderBy() : string|null
Return values
string|null

The ORDER BY clause or null if it was not set

renderProcedure()

protected renderProcedure() : string|null
Return values
string|null

renderValue()

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|string

setLimit()

Sets the LIMIT clause.

protected setLimit(int $limit[, int|null $offset = null ]) : static
Parameters
$limit : int
$offset : int|null = null
Tags
see
https://mariadb.com/kb/en/limit/
Return values
static

Search results