Where
Trait Where.
Table of Contents
- 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.
- 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.
- renderWhere() : string|null
- Renders the full WHERE (or HAVING) clause.
- addWhere() : static
- Adds a WHERE (or HAVING) part.
- prepareWhereValues() : array<string|int, float|int|string>
- Quote the input values or transform it in subqueries.
- 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`.
Methods
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 —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 —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
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 —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
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