Delete
extends Statement
in package
Uses
Join, OrderBy, Where
Class Delete.
Tags
Table of Contents
- OPT_IGNORE = 'IGNORE'
- OPT_LOW_PRIORITY = 'LOW_PRIORITY'
- OPT_QUICK = 'QUICK'
- $database : Database
- $sql : array<string|int, mixed>
- SQL clauses and parts.
- __construct() : mixed
- Statement constructor.
- __toString() : string
- 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".
- from() : static
- Sets the FROM 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".
- 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.
- 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.
- orWhere() : static
- Appends a "OR $column $operator ...$values" condition in the WHERE clause.
- orWhereBetween() : static
- Appends a "OR $column BETWEEN $min AND $max" condition in the WHERE clause.
- orWhereEqual() : static
- Appends a "OR $column = $value" condition in the WHERE clause.
- orWhereGreaterThan() : static
- Appends a "OR $column > $value" condition in the WHERE clause.
- orWhereGreaterThanOrEqual() : static
- Appends a "OR $column >= $value" condition in the WHERE clause.
- orWhereIn() : static
- Appends a "OR $column IN (...$values)" condition in the WHERE clause.
- orWhereIsNotNull() : static
- Appends a "OR $column IS NOT NULL" condition in the WHERE clause.
- orWhereIsNull() : static
- Appends a "OR $column IS NULL" condition in the WHERE clause.
- orWhereLessThan() : static
- Appends a "OR $column < $value" condition in the WHERE clause.
- orWhereLessThanOrEqual() : static
- Appends a "OR $column <= $value" condition in the WHERE clause.
- orWhereLike() : static
- Appends a "OR $column LIKE $value" condition in the WHERE clause.
- orWhereMatch() : static
- Appends a "OR MATCH (...$columns) AGAINST ($against IN NATURAL LANGUAGE MODE)" fulltext searching in the WHERE clause.
- orWhereMatchInBooleanMode() : static
- Appends a "OR MATCH (...$columns) AGAINST ($against IN BOOLEAN MODE)" fulltext searching in the WHERE clause.
- orWhereMatchWithQueryExpansion() : static
- Appends a "OR MATCH (...$columns) AGAINST ($against WITH QUERY EXPANSION)" fulltext searching in the WHERE clause.
- orWhereNotBetween() : static
- Appends a "OR $column NOT BETWEEN $min AND $max" condition in the WHERE clause.
- orWhereNotEqual() : static
- Appends a "OR $column != $value" condition in the WHERE clause.
- orWhereNotIn() : static
- Appends a "OR $column NOT IN (...$values)" condition in the WHERE clause.
- orWhereNotLike() : static
- Appends a "OR $column NOT LIKE $value" condition in the WHERE clause.
- orWhereNullSafeEqual() : static
- Appends a "OR $column <=> $value" condition in the WHERE clause.
- 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() : int|string
- Runs the DELETE statement.
- sql() : string
- Renders de DELETE statement.
- table() : static
- Sets the table references.
- where() : static
- Appends an "AND $column $operator ...$values" condition in the WHERE clause.
- whereBetween() : static
- Appends an "AND $column BETWEEN $min AND $max" condition in the WHERE clause.
- whereEqual() : static
- Appends an "AND $column = $value" condition in the WHERE clause.
- whereGreaterThan() : static
- Appends an "AND $column > $value" condition in the WHERE clause.
- whereGreaterThanOrEqual() : static
- Appends an "AND $column >= $value" condition in the WHERE clause.
- whereIn() : static
- Appends an "AND $column IN (...$values)" condition in the WHERE clause.
- whereIsNotNull() : static
- Appends an "AND $column IS NOT NULL" condition in the WHERE clause.
- whereIsNull() : static
- Appends an "AND $column IS NULL" condition in the WHERE clause.
- whereLessThan() : static
- Appends an "AND $column < $value" condition in the WHERE clause.
- whereLessThanOrEqual() : static
- Appends an "AND $column <= $value" condition in the WHERE clause.
- whereLike() : static
- Appends an "AND $column LIKE $value" condition in the WHERE clause.
- whereMatch() : static
- Appends an "AND MATCH (...$columns) AGAINST ($against IN NATURAL LANGUAGE MODE)" fulltext searching in the WHERE clause.
- whereMatchInBooleanMode() : static
- Appends an "AND MATCH (...$columns) AGAINST ($against IN BOOLEAN MODE)" fulltext searching in the WHERE clause.
- whereMatchWithQueryExpansion() : static
- Appends an "AND MATCH (...$columns) AGAINST ($against WITH QUERY EXPANSION)" fulltext searching in the WHERE clause.
- whereNotBetween() : static
- Appends an "AND $column NOT BETWEEN $min AND $max" condition in the WHERE clause.
- whereNotEqual() : static
- Appends an "AND $column != $value" condition in the WHERE clause.
- whereNotIn() : static
- Appends an "AND $column NOT IN (...$values)" condition in the WHERE clause.
- whereNotLike() : static
- Appends an "AND $column NOT LIKE $value" condition.
- whereNullSafeEqual() : static
- Appends an "AND $column <=> $value" condition in the WHERE clause.
- 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.
- renderFrom() : string|null
- Renders the FROM clause.
- renderIdentifier() : string
- Renders a column part.
- renderJoin() : string|null
- Renders the JOIN clause.
- renderLimit() : string|null
- Renders the LIMIT clause.
- renderOptions() : string|null
- renderOrderBy() : string|null
- Renders the ORDER BY clause.
- renderTable() : string|null
- Renders the table references.
- renderValue() : float|int|string
- Renders a subquery or quote a value.
- renderWhere() : string|null
- Renders the full WHERE (or HAVING) clause.
- setLimit() : static
- Sets the LIMIT clause.
- subquery() : string
- Returns an SQL part between parentheses.
- addOrderBy() : static
- Adds a ORDER BY expression.
- addWhere() : static
- Adds a WHERE (or HAVING) part.
- checkNaturalJoinType() : bool
- Check if a JOIN type belongs to the NATURAL group.
- prepareWhereValues() : array<string|int, float|int|string>
- Quote the input values or transform it in subqueries.
- renderJoinConditional() : string
- Renders the JOIN conditional part.
- renderJoinConditionClause() : string|null
- Validates and renders the JOIN condition clause.
- renderJoinConditionExpression() : string|null
- Renders the JOIN condition expression.
- renderJoinType() : string
- Validates and renders the JOIN type.
- renderMatch() : string
- Renders a MATCH AGAINST clause.
- renderMatchColumns() : string
- renderMatchExpression() : float|int|string
- renderWhereOperator() : string
- Renders and validates a comparison operator.
- renderWherePart() : string
- Renders a WHERE part. Like: `AND column IN('value1', 'value2')`.
- renderWhereValues() : string|null
- Renders the values used by a comparison operator.
- renderWhereValuesPartBetween() : string
- Renders values for `BETWEEN` or `NOT BETWEEN`.
- renderWhereValuesPartComparator() : string
- Renders the values of operators that receive exactly one value.
- renderWhereValuesPartIn() : string
- Implode values for `IN` or `NOT IN`.
- renderWhereValuesPartIsNull() : null
- Renders the lonely operators, `IS NULL` or `IS NOT NULL`.
- setJoin() : static
- Sets the JOIN clause.
Constants
OPT_IGNORE
public
string
OPT_IGNORE
= 'IGNORE'
OPT_LOW_PRIORITY
public
string
OPT_LOW_PRIORITY
= 'LOW_PRIORITY'
OPT_QUICK
public
string
OPT_QUICK
= 'QUICK'
Properties
$database
protected
Database
$database
$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 —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 —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
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 —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 asINNER
) - $clause : string|null = null
-
Condition clause. Null if it has a NATURAL type, otherwise
ON
orUSING
- $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) : static
Parameters
- $limit : int
Tags
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 —orWhere()
Appends a "OR $column $operator ...$values" condition in the WHERE clause.
public
orWhere(array<string|int, array|\Closure|string>|Closure|string $column, string $operator, array<string|int, array|\Closure|float|int|string|null>|Closure|float|int|string|null ...$values) : static
Parameters
- $column : array<string|int, array|\Closure|string>|Closure|string
-
Closure for a subquery, a string with the column name or an array with column names on WHERE MATCH clause
- $operator : string
- $values : array<string|int, array|\Closure|float|int|string|null>|Closure|float|int|string|null
Return values
static —orWhereBetween()
Appends a "OR $column BETWEEN $min AND $max" condition in the WHERE clause.
public
orWhereBetween(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
Return values
static —orWhereEqual()
Appends a "OR $column = $value" condition in the WHERE clause.
public
orWhereEqual(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
Return values
static —orWhereGreaterThan()
Appends a "OR $column > $value" condition in the WHERE clause.
public
orWhereGreaterThan(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
Return values
static —orWhereGreaterThanOrEqual()
Appends a "OR $column >= $value" condition in the WHERE clause.
public
orWhereGreaterThanOrEqual(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
Return values
static —orWhereIn()
Appends a "OR $column IN (...$values)" condition in the WHERE clause.
public
orWhereIn(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
Return values
static —orWhereIsNotNull()
Appends a "OR $column IS NOT NULL" condition in the WHERE clause.
public
orWhereIsNotNull(Closure|string $column) : static
Parameters
- $column : Closure|string
-
Closure for a subquery or a string with the column name
Tags
Return values
static —orWhereIsNull()
Appends a "OR $column IS NULL" condition in the WHERE clause.
public
orWhereIsNull(Closure|string $column) : static
Parameters
- $column : Closure|string
-
Closure for a subquery or a string with the column name
Tags
Return values
static —orWhereLessThan()
Appends a "OR $column < $value" condition in the WHERE clause.
public
orWhereLessThan(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
Return values
static —orWhereLessThanOrEqual()
Appends a "OR $column <= $value" condition in the WHERE clause.
public
orWhereLessThanOrEqual(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
Return values
static —orWhereLike()
Appends a "OR $column LIKE $value" condition in the WHERE clause.
public
orWhereLike(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
Return values
static —orWhereMatch()
Appends a "OR MATCH (...$columns) AGAINST ($against IN NATURAL LANGUAGE MODE)" fulltext searching in the WHERE clause.
public
orWhereMatch(array<string|int, array|\Closure|string>|Closure|string $columns, array<string|int, array|\Closure|string>|Closure|string $against) : static
Parameters
- $columns : array<string|int, array|\Closure|string>|Closure|string
-
Columns to MATCH
- $against : array<string|int, array|\Closure|string>|Closure|string
-
AGAINST expression
Tags
Return values
static —orWhereMatchInBooleanMode()
Appends a "OR MATCH (...$columns) AGAINST ($against IN BOOLEAN MODE)" fulltext searching in the WHERE clause.
public
orWhereMatchInBooleanMode(array<string|int, array|\Closure|string>|Closure|string $columns, array<string|int, array|\Closure|string>|Closure|string $against) : static
Parameters
- $columns : array<string|int, array|\Closure|string>|Closure|string
-
Columns to MATCH
- $against : array<string|int, array|\Closure|string>|Closure|string
-
AGAINST expression
Tags
Return values
static —orWhereMatchWithQueryExpansion()
Appends a "OR MATCH (...$columns) AGAINST ($against WITH QUERY EXPANSION)" fulltext searching in the WHERE clause.
public
orWhereMatchWithQueryExpansion(array<string|int, array|\Closure|string>|Closure|string $columns, array<string|int, array|\Closure|string>|Closure|string $against) : static
Parameters
- $columns : array<string|int, array|\Closure|string>|Closure|string
-
Columns to MATCH
- $against : array<string|int, array|\Closure|string>|Closure|string
-
AGAINST expression
Tags
Return values
static —orWhereNotBetween()
Appends a "OR $column NOT BETWEEN $min AND $max" condition in the WHERE clause.
public
orWhereNotBetween(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
Return values
static —orWhereNotEqual()
Appends a "OR $column != $value" condition in the WHERE clause.
public
orWhereNotEqual(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
Return values
static —orWhereNotIn()
Appends a "OR $column NOT IN (...$values)" condition in the WHERE clause.
public
orWhereNotIn(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
Return values
static —orWhereNotLike()
Appends a "OR $column NOT LIKE $value" condition in the WHERE clause.
public
orWhereNotLike(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
Return values
static —orWhereNullSafeEqual()
Appends a "OR $column <=> $value" condition in the WHERE clause.
public
orWhereNullSafeEqual(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
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
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 —run()
Runs the DELETE statement.
public
run() : int|string
Return values
int|string —The number of affected rows
sql()
Renders de DELETE statement.
public
sql() : string
Return values
string —table()
Sets the table references.
public
table(array<string, \Closure|string>|Closure|string $reference, array<string, \Closure|string>|Closure|string ...$references) : static
Parameters
- $reference : array<string, \Closure|string>|Closure|string
-
The table name as string, a subquery as Closure or an array for aliased table where the key is the alias name and the value is the table name or a subquery
- $references : array<string, \Closure|string>|Closure|string
-
Extra references. Same values as $reference
Return values
static —where()
Appends an "AND $column $operator ...$values" condition in the WHERE clause.
public
where(array<string|int, array|\Closure|string>|Closure|string $column, string $operator, array<string|int, array|\Closure|float|int|string|null>|Closure|float|int|string|null ...$values) : static
Parameters
- $column : array<string|int, array|\Closure|string>|Closure|string
-
Closure for a subquery, a string with the column name or an array with column names on WHERE MATCH clause
- $operator : string
- $values : array<string|int, array|\Closure|float|int|string|null>|Closure|float|int|string|null
Return values
static —whereBetween()
Appends an "AND $column BETWEEN $min AND $max" condition in the WHERE clause.
public
whereBetween(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
Return values
static —whereEqual()
Appends an "AND $column = $value" condition in the WHERE clause.
public
whereEqual(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
Return values
static —whereGreaterThan()
Appends an "AND $column > $value" condition in the WHERE clause.
public
whereGreaterThan(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
Return values
static —whereGreaterThanOrEqual()
Appends an "AND $column >= $value" condition in the WHERE clause.
public
whereGreaterThanOrEqual(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
Return values
static —whereIn()
Appends an "AND $column IN (...$values)" condition in the WHERE clause.
public
whereIn(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
Return values
static —whereIsNotNull()
Appends an "AND $column IS NOT NULL" condition in the WHERE clause.
public
whereIsNotNull(Closure|string $column) : static
Parameters
- $column : Closure|string
-
Closure for a subquery or a string with the column name
Tags
Return values
static —whereIsNull()
Appends an "AND $column IS NULL" condition in the WHERE clause.
public
whereIsNull(Closure|string $column) : static
Parameters
- $column : Closure|string
-
Closure for a subquery or a string with the column name
Tags
Return values
static —whereLessThan()
Appends an "AND $column < $value" condition in the WHERE clause.
public
whereLessThan(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
Return values
static —whereLessThanOrEqual()
Appends an "AND $column <= $value" condition in the WHERE clause.
public
whereLessThanOrEqual(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
Return values
static —whereLike()
Appends an "AND $column LIKE $value" condition in the WHERE clause.
public
whereLike(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
Return values
static —whereMatch()
Appends an "AND MATCH (...$columns) AGAINST ($against IN NATURAL LANGUAGE MODE)" fulltext searching in the WHERE clause.
public
whereMatch(array<string|int, array|\Closure|string>|Closure|string $columns, array<string|int, array|\Closure|string>|Closure|string $against) : static
Parameters
- $columns : array<string|int, array|\Closure|string>|Closure|string
-
Columns to MATCH
- $against : array<string|int, array|\Closure|string>|Closure|string
-
AGAINST expression
Tags
Return values
static —whereMatchInBooleanMode()
Appends an "AND MATCH (...$columns) AGAINST ($against IN BOOLEAN MODE)" fulltext searching in the WHERE clause.
public
whereMatchInBooleanMode(array<string|int, array|\Closure|string>|Closure|string $columns, array<string|int, array|\Closure|string>|Closure|string $against) : static
Parameters
- $columns : array<string|int, array|\Closure|string>|Closure|string
-
Columns to MATCH
- $against : array<string|int, array|\Closure|string>|Closure|string
-
AGAINST expression
Tags
Return values
static —whereMatchWithQueryExpansion()
Appends an "AND MATCH (...$columns) AGAINST ($against WITH QUERY EXPANSION)" fulltext searching in the WHERE clause.
public
whereMatchWithQueryExpansion(array<string|int, array|\Closure|string>|Closure|string $columns, array<string|int, array|\Closure|string>|Closure|string $against) : static
Parameters
- $columns : array<string|int, array|\Closure|string>|Closure|string
-
Columns to MATCH
- $against : array<string|int, array|\Closure|string>|Closure|string
-
AGAINST expression
Tags
Return values
static —whereNotBetween()
Appends an "AND $column NOT BETWEEN $min AND $max" condition in the WHERE clause.
public
whereNotBetween(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
Return values
static —whereNotEqual()
Appends an "AND $column != $value" condition in the WHERE clause.
public
whereNotEqual(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
Return values
static —whereNotIn()
Appends an "AND $column NOT IN (...$values)" condition in the WHERE clause.
public
whereNotIn(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
Return values
static —whereNotLike()
Appends an "AND $column NOT LIKE $value" condition.
public
whereNotLike(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
Return values
static —whereNullSafeEqual()
Appends an "AND $column <=> $value" condition in the WHERE clause.
public
whereNullSafeEqual(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
Return values
static —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
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 —renderAssignment()
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
string —renderFrom()
Renders the FROM clause.
protected
renderFrom() : string|null
Return values
string|null —The FROM clause or null if it was not set
renderIdentifier()
Renders a column part.
protected
renderIdentifier(Closure|string $column) : string
Parameters
- $column : Closure|string
-
The column name or a subquery
Return values
string —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 —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
renderTable()
Renders the table references.
protected
renderTable() : string|null
Return values
string|null —The table references or null if none was set
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 —renderWhere()
Renders the full WHERE (or HAVING) clause.
protected
renderWhere([string $clause = 'where' ]) : string|null
Parameters
- $clause : string = 'where'
-
where
orhaving
Return values
string|null —The full clause or null if has not a clause
setLimit()
Sets the LIMIT clause.
protected
setLimit(int $limit[, int|null $offset = null ]) : static
Parameters
- $limit : int
- $offset : int|null = null
Tags
Return values
static —subquery()
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
Tags
Return values
string —addOrderBy()
Adds a ORDER BY expression.
private
addOrderBy(Closure|string $column, array<string|int, \Closure|string> $columns, string|null $direction) : static
Parameters
- $column : Closure|string
-
The column name or a subquery
- $columns : array<string|int, \Closure|string>
-
Extra column names and/or subqueries
- $direction : string|null
-
ASC
,DESC
or null for none
Return values
static —addWhere()
Adds a WHERE (or HAVING) part.
private
addWhere(string $glue, array<string|int, array|\Closure|string>|Closure|string $column, string $operator, array<string|int, \Closure|float|int|string|null> $values[, string $clause = 'where' ]) : static
Parameters
- $glue : string
-
AND
orOR
- $column : array<string|int, array|\Closure|string>|Closure|string
- $operator : string
-
=
,<=>
,!=
,<>
,>
,>=
,<
,<=
,LIKE
,NOT LIKE
,IN
,NOT IN
,BETWEEN
,NOT BETWEEN
,IS NULL
,IS NOT NULL
orMATCH
- $values : array<string|int, \Closure|float|int|string|null>
-
Values used by the operator
- $clause : string = 'where'
-
where
orhaving
Return values
static —checkNaturalJoinType()
Check if a JOIN type belongs to the NATURAL group.
private
checkNaturalJoinType(string $type, string|null $clause, array<string|int, \Closure|string>|Closure|null $expression) : bool
Parameters
- $type : string
-
NATURAL
,NATURAL LEFT
,NATURAL LEFT OUTER
,NATURAL RIGHT
,NATURAL RIGHT OUTER
or any other non-natural - $clause : string|null
-
Must be null if type is natural
- $expression : array<string|int, \Closure|string>|Closure|null
-
Must be null if type is natural
Tags
Return values
bool —True if the type is natural, otherwise false
prepareWhereValues()
Quote the input values or transform it in subqueries.
private
prepareWhereValues(array<string|int, bool|\Closure|float|int|string|null> $values) : array<string|int, float|int|string>
Parameters
- $values : array<string|int, bool|\Closure|float|int|string|null>
Return values
array<string|int, float|int|string> —Each input value quoted or transformed in subquery
renderJoinConditional()
Renders the JOIN conditional part.
private
renderJoinConditional(string $type, array<string, \Closure|string>|Closure|string $table, string|null $clause, array<string|int, \Closure|string>|Closure|null $expression) : string
Parameters
- $type : string
-
``,
CROSS
,INNER
,LEFT
,LEFT OUTER
,RIGHT
,RIGHT OUTER
,NATURAL
,NATURAL LEFT
,NATURAL LEFT OUTER
,NATURAL RIGHT
orNATURAL RIGHT OUTER
- $table : array<string, \Closure|string>|Closure|string
-
The table name
- $clause : string|null
-
ON
,USING
or null for none - $expression : array<string|int, \Closure|string>|Closure|null
-
Column(s) or subquery(ies)
Return values
string —The JOIN conditional part
renderJoinConditionClause()
Validates and renders the JOIN condition clause.
private
renderJoinConditionClause(string|null $clause) : string|null
Parameters
- $clause : string|null
-
ON
,USING
or null for none
Tags
Return values
string|null —The condition clause or none
renderJoinConditionExpression()
Renders the JOIN condition expression.
private
renderJoinConditionExpression(string|null $clause, array<string|int, \Closure|string>|Closure|null $expression) : string|null
Parameters
- $clause : string|null
-
ON
or null - $expression : array<string|int, \Closure|string>|Closure|null
-
Column(s) or subquery(ies)
Return values
string|null —The condition or null if $clause is null
renderJoinType()
Validates and renders the JOIN type.
private
renderJoinType(string $type) : string
Parameters
- $type : string
-
``,
CROSS
,INNER
,LEFT
,LEFT OUTER
,RIGHT
,RIGHT OUTER
,NATURAL
,NATURAL LEFT
,NATURAL LEFT OUTER
,NATURAL RIGHT
orNATURAL RIGHT OUTER
Tags
Return values
string —The input ype
renderMatch()
Renders a MATCH AGAINST clause.
private
renderMatch(array<string|int, \Closure|string>|Closure|string $columns, array<string|int, string>|Closure|string $expression[, string $modifier = '' ]) : string
Parameters
- $columns : array<string|int, \Closure|string>|Closure|string
- $expression : array<string|int, string>|Closure|string
- $modifier : string = ''
Return values
string —renderMatchColumns()
private
renderMatchColumns(array<string|int, \Closure|string>|Closure|string $columns) : string
Parameters
- $columns : array<string|int, \Closure|string>|Closure|string
Return values
string —renderMatchExpression()
private
renderMatchExpression(array<string|int, string>|Closure|string $expression) : float|int|string
Parameters
- $expression : array<string|int, string>|Closure|string
Return values
float|int|string —renderWhereOperator()
Renders and validates a comparison operator.
private
renderWhereOperator(string $operator) : string
Parameters
- $operator : string
-
=
,<=>
,!=
,<>
,>
,>=
,<
,<=
,LIKE
,NOT LIKE
,IN
,NOT IN
,BETWEEN
,NOT BETWEEN
,IS NULL
orIS NOT NULL
Tags
Return values
string —The operator
renderWherePart()
Renders a WHERE part. Like: `AND column IN('value1', 'value2')`.
private
renderWherePart(array<string, mixed> $part[, bool $first = false ]) : string
Parameters
- $part : array<string, mixed>
-
Keys:
glue
,operator
,column
andvalues
- $first : bool = false
-
Is the first part? Prepends the operator (
AND
orOR
)
Return values
string —renderWhereValues()
Renders the values used by a comparison operator.
private
renderWhereValues(string $operator, array<string|int, \Closure|float|int|string|null> $values) : string|null
Parameters
- $operator : string
-
=
,<=>
,!=
,<>
,>
,>=
,<
,<=
,LIKE
,NOT LIKE
,IN
,NOT IN
,BETWEEN
,NOT BETWEEN
,IS NULL
orIS NOT NULL
- $values : array<string|int, \Closure|float|int|string|null>
Tags
Return values
string|null —The values used by the operator
renderWhereValuesPartBetween()
Renders values for `BETWEEN` or `NOT BETWEEN`.
private
renderWhereValuesPartBetween(string $operator, array<string|int, float|int|string> $values) : string
Parameters
- $operator : string
-
BETWEEN
orNOT BETWEEN
- $values : array<string|int, float|int|string>
-
Two values, indexes 0 and 1
Tags
Return values
string —renderWhereValuesPartComparator()
Renders the values of operators that receive exactly one value.
private
renderWhereValuesPartComparator(string $operator, array<string|int, float|int|string> $values) : string
Parameters
- $operator : string
-
=
,<=>
,!=
,<>
,>
,>=
,<
,<=
,LIKE
orNOT LIKE
- $values : array<string|int, float|int|string>
-
Must receive exactly 1 value, index 0
Tags
Return values
string —renderWhereValuesPartIn()
Implode values for `IN` or `NOT IN`.
private
renderWhereValuesPartIn(string $operator, array<string|int, float|int|string> $values) : string
Parameters
- $operator : string
-
IN
orNOT IN
- $values : array<string|int, float|int|string>
-
Must receive at least 1 value
Tags
Return values
string —renderWhereValuesPartIsNull()
Renders the lonely operators, `IS NULL` or `IS NOT NULL`.
private
renderWhereValuesPartIsNull(string $operator, array<string|int, float|int|string> $values) : null
Parameters
- $operator : string
-
IS NULL
orIS NOT NULL
- $values : array<string|int, float|int|string>
-
Must be an empty array
Tags
Return values
null —setJoin()
Sets the JOIN clause.
private
setJoin(array<string, \Closure|string>|Closure|string $table, string $type[, string|null $clause = null ][, array<string|int, \Closure|string>|Closure|null $expression = null ]) : static
Parameters
- $table : array<string, \Closure|string>|Closure|string
-
The table factor
- $type : string
-
``,
CROSS
,INNER
,LEFT
,LEFT OUTER
,RIGHT
,RIGHT OUTER
,NATURAL
,NATURAL LEFT
,NATURAL LEFT OUTER
,NATURAL RIGHT
orNATURAL RIGHT OUTER
- $clause : string|null = null
-
ON
,USING
or null for none - $expression : array<string|int, \Closure|string>|Closure|null = null
-
Column(s) or subquery(ies)