Having trait

Framework\Database\Manipulation\Traits\Having

Trait Having.

Defined in libraries/database/src/Manipulation/Traits/Having.php

Methods #

having()
Appends an "AND $column $operator ...$values" condition in the HAVING clause.
havingBetween()
Appends an "AND $column BETWEEN $min AND $max" condition in the HAVING clause.
havingEqual()
Appends an "AND $column = $value" condition in the HAVING clause.
havingGreaterThan()
Appends an "AND $column > $value" condition in the HAVING clause.
havingGreaterThanOrEqual()
Appends an "AND $column >= $value" condition in the HAVING clause.
havingIn()
Appends an "AND $column IN (...$values)" condition in the HAVING clause.
havingIsNotNull()
Appends an "AND $column IS NOT NULL" condition in the HAVING clause.
havingIsNull()
Appends an "AND $column IS NULL" condition in the HAVING clause.
havingLessThan()
Appends an "AND $column < $value" condition in the HAVING clause.
havingLessThanOrEqual()
Appends an "AND $column <= $value" condition in the HAVING clause.
havingLike()
Appends an "AND $column LIKE $value" condition in the HAVING clause.
havingNotBetween()
Appends an "AND $column NOT BETWEEN $min AND $max" condition in the HAVING clause.
havingNotEqual()
Appends an "AND $column != $value" condition in the HAVING clause.
havingNotIn()
Appends an "AND $column NOT IN (...$values)" condition in the HAVING clause.
havingNotLike()
Appends an "AND $column NOT LIKE" $value condition.
havingNullSafeEqual()
Appends an "AND $column <=> $value" condition in the HAVING clause.
orHaving()
Appends a "OR $column $operator ...$values" condition in the HAVING clause.
orHavingBetween()
Appends a "OR $column BETWEEN $min AND $max" condition in the HAVING clause.
orHavingEqual()
Appends a "OR $column = $value" condition in the HAVING clause.
orHavingGreaterThan()
Appends a "OR $column > $value" condition in the HAVING clause.
orHavingGreaterThanOrEqual()
Appends a "OR $column >= $value" condition in the HAVING clause.
orHavingIn()
Appends a "OR $column IN (...$values)" condition in the HAVING clause.
orHavingIsNotNull()
Appends a "OR $column IS NOT NULL" condition in the HAVING clause.
orHavingIsNull()
Appends a "OR $column IS NULL" condition in the HAVING clause.
orHavingLessThan()
Appends a "OR $column < $value" condition in the HAVING clause.
orHavingLessThanOrEqual()
Appends a "OR $column <= $value" condition in the HAVING clause.
orHavingLike()
Appends a "OR $column LIKE $value" condition in the HAVING clause.
orHavingNotBetween()
Appends a "OR $column NOT BETWEEN $min AND $max" condition in the HAVING clause.
orHavingNotEqual()
Appends a "OR $column != $value" condition in the HAVING clause.
orHavingNotIn()
Appends a "OR $column NOT IN (...$values)" condition in the HAVING clause.
orHavingNotLike()
Appends a "OR $column NOT LIKE $value" condition in the HAVING clause.
orHavingNullSafeEqual()
Appends a "OR $column <=> $value" condition in the HAVING clause.
orWhere()
Appends a "OR $column $operator ...$values" condition in the WHERE clause.
orWhereBetween()
Appends a "OR $column BETWEEN $min AND $max" condition in the WHERE clause.
orWhereEqual()
Appends a "OR $column = $value" condition in the WHERE clause.
orWhereGreaterThan()
Appends a "OR $column > $value" condition in the WHERE clause.
orWhereGreaterThanOrEqual()
Appends a "OR $column >= $value" condition in the WHERE clause.
orWhereIn()
Appends a "OR $column IN (...$values)" condition in the WHERE clause.
orWhereIsNotNull()
Appends a "OR $column IS NOT NULL" condition in the WHERE clause.
orWhereIsNull()
Appends a "OR $column IS NULL" condition in the WHERE clause.
orWhereLessThan()
Appends a "OR $column < $value" condition in the WHERE clause.
orWhereLessThanOrEqual()
Appends a "OR $column <= $value" condition in the WHERE clause.
orWhereLike()
Appends a "OR $column LIKE $value" condition in the WHERE clause.
orWhereMatch()
Appends a "OR MATCH (...$columns) AGAINST ($against IN NATURAL LANGUAGE MODE)" fulltext searching in the WHERE clause.
orWhereMatchInBooleanMode()
Appends a "OR MATCH (...$columns) AGAINST ($against IN BOOLEAN MODE)" fulltext searching in the WHERE clause.
orWhereMatchWithQueryExpansion()
Appends a "OR MATCH (...$columns) AGAINST ($against WITH QUERY EXPANSION)" fulltext searching in the WHERE clause.
orWhereNotBetween()
Appends a "OR $column NOT BETWEEN $min AND $max" condition in the WHERE clause.
orWhereNotEqual()
Appends a "OR $column != $value" condition in the WHERE clause.
orWhereNotIn()
Appends a "OR $column NOT IN (...$values)" condition in the WHERE clause.
orWhereNotLike()
Appends a "OR $column NOT LIKE $value" condition in the WHERE clause.
orWhereNullSafeEqual()
Appends a "OR $column <=> $value" condition in the WHERE clause.
where()
Appends an "AND $column $operator ...$values" condition in the WHERE clause.
whereBetween()
Appends an "AND $column BETWEEN $min AND $max" condition in the WHERE clause.
whereEqual()
Appends an "AND $column = $value" condition in the WHERE clause.
whereGreaterThan()
Appends an "AND $column > $value" condition in the WHERE clause.
whereGreaterThanOrEqual()
Appends an "AND $column >= $value" condition in the WHERE clause.
whereIn()
Appends an "AND $column IN (...$values)" condition in the WHERE clause.
whereIsNotNull()
Appends an "AND $column IS NOT NULL" condition in the WHERE clause.
whereIsNull()
Appends an "AND $column IS NULL" condition in the WHERE clause.
whereLessThan()
Appends an "AND $column < $value" condition in the WHERE clause.
whereLessThanOrEqual()
Appends an "AND $column <= $value" condition in the WHERE clause.
whereLike()
Appends an "AND $column LIKE $value" condition in the WHERE clause.
whereMatch()
Appends an "AND MATCH (...$columns) AGAINST ($against IN NATURAL LANGUAGE MODE)" fulltext searching in the WHERE clause.
whereMatchInBooleanMode()
Appends an "AND MATCH (...$columns) AGAINST ($against IN BOOLEAN MODE)" fulltext searching in the WHERE clause.
whereMatchWithQueryExpansion()
Appends an "AND MATCH (...$columns) AGAINST ($against WITH QUERY EXPANSION)" fulltext searching in the WHERE clause.
whereNotBetween()
Appends an "AND $column NOT BETWEEN $min AND $max" condition in the WHERE clause.
whereNotEqual()
Appends an "AND $column != $value" condition in the WHERE clause.
whereNotIn()
Appends an "AND $column NOT IN (...$values)" condition in the WHERE clause.
whereNotLike()
Appends an "AND $column NOT LIKE $value" condition.
whereNullSafeEqual()
Appends an "AND $column <=> $value" condition in the WHERE clause.
renderHaving()
Renders the full HAVING clause.
renderWhere()
Renders the full WHERE (or HAVING) clause.
addHaving()
Adds a HAVING part.
addWhere()
Adds a WHERE (or HAVING) part.
prepareWhereValues()
Quote the input values or transform it in subqueries.
renderMatch()
Renders a MATCH AGAINST clause.
renderMatchColumns()
-
renderMatchExpression()
-
renderWhereOperator()
Renders and validates a comparison operator.
renderWherePart()
Renders a WHERE part. Like: `AND column IN('value1', 'value2')`.
renderWhereValues()
Renders the values used by a comparison operator.
renderWhereValuesPartBetween()
Renders values for `BETWEEN` or `NOT BETWEEN`.
renderWhereValuesPartComparator()
Renders the values of operators that receive exactly one value.
renderWhereValuesPartIn()
Implode values for `IN` or `NOT IN`.
renderWhereValuesPartIsNull()
Renders the lonely operators, `IS NULL` or `IS NOT NULL`.

having()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • string $operator
  • Closure|string|int|float|null $values
Returns static

havingBetween()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $min
  • Closure|string|int|float|null $max
Returns static

havingEqual()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
Returns static

havingGreaterThan()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
Returns static

havingGreaterThanOrEqual()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
Returns static

havingIn()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
  • Closure|string|int|float|null $values
Returns static

havingIsNotNull()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
Returns static

havingIsNull()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
Returns static

havingLessThan()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
Returns static

havingLessThanOrEqual()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
Returns static

havingLike()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
Returns static

havingNotBetween()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $min
  • Closure|string|int|float|null $max
Returns static

havingNotEqual()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
Returns static

havingNotIn()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
  • Closure|string|int|float|null $values
Returns static

havingNotLike()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
Returns static

havingNullSafeEqual()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
Returns static

orHaving()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • string $operator
  • Closure|string|int|float|null $values
Returns static

orHavingBetween()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $min
  • Closure|string|int|float|null $max
Returns static

orHavingEqual()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
Returns static

orHavingGreaterThan()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
Returns static

orHavingGreaterThanOrEqual()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
Returns static

orHavingIn()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
  • Closure|string|int|float|null $values
Returns static

orHavingIsNotNull()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
Returns static

orHavingIsNull()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
Returns static

orHavingLessThan()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
Returns static

orHavingLessThanOrEqual()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
Returns static

orHavingLike()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
Returns static

orHavingNotBetween()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $min
  • Closure|string|int|float|null $max
Returns static

orHavingNotEqual()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
Returns static

orHavingNotIn()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
  • Closure|string|int|float|null $values
Returns static

orHavingNotLike()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
Returns static

orHavingNullSafeEqual()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
Returns static

orWhere()

public function orWhere(Closure|array|string $column, string $operator, Closure|array|string|int|float|null ...$values): static

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

Parameters
  • Closure|array|string $column - Closure for a subquery, a string with the column name or an array with column names on WHERE MATCH clause
  • string $operator
  • Closure|array|string|int|float|null $values
Returns static

orWhereBetween()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $min
  • Closure|string|int|float|null $max
Returns static

orWhereEqual()

public function orWhereEqual(Closure|string $column, Closure|string|int|float|null $value): static

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
Returns static

orWhereGreaterThan()

public function orWhereGreaterThan(Closure|string $column, Closure|string|int|float|null $value): static

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
Returns static

orWhereGreaterThanOrEqual()

public function orWhereGreaterThanOrEqual(Closure|string $column, Closure|string|int|float|null $value): static

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
Returns static

orWhereIn()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
  • Closure|string|int|float|null $values
Returns static

orWhereIsNotNull()

public function orWhereIsNotNull(Closure|string $column): static

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
Returns static

orWhereIsNull()

public function orWhereIsNull(Closure|string $column): static

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
Returns static

orWhereLessThan()

public function orWhereLessThan(Closure|string $column, Closure|string|int|float|null $value): static

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
Returns static

orWhereLessThanOrEqual()

public function orWhereLessThanOrEqual(Closure|string $column, Closure|string|int|float|null $value): static

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
Returns static

orWhereLike()

public function orWhereLike(Closure|string $column, Closure|string|int|float|null $value): static

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
Returns static

orWhereMatch()

public function orWhereMatch(Closure|array|string $columns, Closure|array|string $against): static

Appends a "OR MATCH (...$columns) AGAINST ($against IN NATURAL LANGUAGE MODE)" fulltext searching in the WHERE clause.

Parameters
  • Closure|array|string $columns - Columns to MATCH
  • Closure|array|string $against - AGAINST expression
Returns static

orWhereMatchInBooleanMode()

public function orWhereMatchInBooleanMode(Closure|array|string $columns, Closure|array|string $against): static

Appends a "OR MATCH (...$columns) AGAINST ($against IN BOOLEAN MODE)" fulltext searching in the WHERE clause.

Parameters
  • Closure|array|string $columns - Columns to MATCH
  • Closure|array|string $against - AGAINST expression
Returns static

orWhereMatchWithQueryExpansion()

public function orWhereMatchWithQueryExpansion(Closure|array|string $columns, Closure|array|string $against): static

Appends a "OR MATCH (...$columns) AGAINST ($against WITH QUERY EXPANSION)" fulltext searching in the WHERE clause.

Parameters
  • Closure|array|string $columns - Columns to MATCH
  • Closure|array|string $against - AGAINST expression
Returns static

orWhereNotBetween()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $min
  • Closure|string|int|float|null $max
Returns static

orWhereNotEqual()

public function orWhereNotEqual(Closure|string $column, Closure|string|int|float|null $value): static

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
Returns static

orWhereNotIn()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
  • Closure|string|int|float|null $values
Returns static

orWhereNotLike()

public function orWhereNotLike(Closure|string $column, Closure|string|int|float|null $value): static

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
Returns static

orWhereNullSafeEqual()

public function orWhereNullSafeEqual(Closure|string $column, Closure|string|int|float|null $value): static

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
Returns static

where()

public function where(Closure|array|string $column, string $operator, Closure|array|string|int|float|null ...$values): static

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

Parameters
  • Closure|array|string $column - Closure for a subquery, a string with the column name or an array with column names on WHERE MATCH clause
  • string $operator
  • Closure|array|string|int|float|null $values
Returns static

whereBetween()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $min
  • Closure|string|int|float|null $max
Returns static

whereEqual()

public function whereEqual(Closure|string $column, Closure|string|int|float|null $value): static

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
Returns static

whereGreaterThan()

public function whereGreaterThan(Closure|string $column, Closure|string|int|float|null $value): static

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
Returns static

whereGreaterThanOrEqual()

public function whereGreaterThanOrEqual(Closure|string $column, Closure|string|int|float|null $value): static

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
Returns static

whereIn()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
  • Closure|string|int|float|null $values
Returns static

whereIsNotNull()

public function whereIsNotNull(Closure|string $column): static

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
Returns static

whereIsNull()

public function whereIsNull(Closure|string $column): static

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
Returns static

whereLessThan()

public function whereLessThan(Closure|string $column, Closure|string|int|float|null $value): static

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
Returns static

whereLessThanOrEqual()

public function whereLessThanOrEqual(Closure|string $column, Closure|string|int|float|null $value): static

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
Returns static

whereLike()

public function whereLike(Closure|string $column, Closure|string|int|float|null $value): static

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
Returns static

whereMatch()

public function whereMatch(Closure|array|string $columns, Closure|array|string $against): static

Appends an "AND MATCH (...$columns) AGAINST ($against IN NATURAL LANGUAGE MODE)" fulltext searching in the WHERE clause.

Parameters
  • Closure|array|string $columns - Columns to MATCH
  • Closure|array|string $against - AGAINST expression
Returns static

whereMatchInBooleanMode()

public function whereMatchInBooleanMode(Closure|array|string $columns, Closure|array|string $against): static

Appends an "AND MATCH (...$columns) AGAINST ($against IN BOOLEAN MODE)" fulltext searching in the WHERE clause.

Parameters
  • Closure|array|string $columns - Columns to MATCH
  • Closure|array|string $against - AGAINST expression
Returns static

whereMatchWithQueryExpansion()

public function whereMatchWithQueryExpansion(Closure|array|string $columns, Closure|array|string $against): static

Appends an "AND MATCH (...$columns) AGAINST ($against WITH QUERY EXPANSION)" fulltext searching in the WHERE clause.

Parameters
  • Closure|array|string $columns - Columns to MATCH
  • Closure|array|string $against - AGAINST expression
Returns static

whereNotBetween()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $min
  • Closure|string|int|float|null $max
Returns static

whereNotEqual()

public function whereNotEqual(Closure|string $column, Closure|string|int|float|null $value): static

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
Returns static

whereNotIn()

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

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
  • Closure|string|int|float|null $values
Returns static

whereNotLike()

public function whereNotLike(Closure|string $column, Closure|string|int|float|null $value): static

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
Returns static

whereNullSafeEqual()

public function whereNullSafeEqual(Closure|string $column, Closure|string|int|float|null $value): static

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

Parameters
  • Closure|string $column - Closure for a subquery or a string with the column name
  • Closure|string|int|float|null $value
Returns static

renderHaving()

protected function renderHaving(): ?string

Renders the full HAVING clause.

Returns ?string - The full clause or null if has not a clause

renderWhere()

protected function renderWhere(string $clause = 'where'): ?string

Renders the full WHERE (or HAVING) clause.

Parameters
  • string $clause - `where` or `having`
Returns ?string - The full clause or null if has not a clause

addHaving()

private function addHaving(string $glue, Closure|array|string $column, string $operator, array $values): static

Adds a HAVING part.

Parameters
  • string $glue - `AND` or `OR`
  • Closure|array|string $column
  • string $operator - `=`, `<=>`, `!=`, `<>`, `>`, `>=`, `<`, `<=`, `LIKE`, `NOT LIKE`, `IN`, `NOT IN`, `BETWEEN`, `NOT BETWEEN`, `IS NULL`, `IS NOT NULL` or `MATCH`
  • array $values - Values used by the operator
Returns static

addWhere()

private function addWhere(string $glue, Closure|array|string $column, string $operator, array $values, string $clause = 'where'): static

Adds a WHERE (or HAVING) part.

Parameters
  • string $glue - `AND` or `OR`
  • Closure|array|string $column
  • string $operator - `=`, `<=>`, `!=`, `<>`, `>`, `>=`, `<`, `<=`, `LIKE`, `NOT LIKE`, `IN`, `NOT IN`, `BETWEEN`, `NOT BETWEEN`, `IS NULL`, `IS NOT NULL` or `MATCH`
  • array $values - Values used by the operator
  • string $clause - `where` or `having`
Returns static

prepareWhereValues()

private function prepareWhereValues(array $values): array

Quote the input values or transform it in subqueries.

Parameters
  • array $values
Returns array - Each input value quoted or transformed in subquery

renderMatch()

private function renderMatch(Closure|array|string $columns, Closure|array|string $expression, string $modifier = '')

Renders a MATCH AGAINST clause.

Parameters
  • Closure|array|string $columns
  • Closure|array|string $expression
  • string $modifier
Returns string

renderMatchColumns()

private function renderMatchColumns(Closure|array|string $columns): string
Parameters
  • Closure|array|string $columns
Returns string

renderMatchExpression()

private function renderMatchExpression(Closure|array|string $expression): string|int|float
Parameters
  • Closure|array|string $expression
Returns string|int|float

renderWhereOperator()

private function renderWhereOperator(string $operator): string

Renders and validates a comparison operator.

Parameters
  • string $operator - `=`, `<=>`, `!=`, `<>`, `>`, `>=`, `<`, `<=`, `LIKE`, `NOT LIKE`, `IN`, `NOT IN`, `BETWEEN`, `NOT BETWEEN`, `IS NULL` or `IS NOT NULL`
Returns string - The operator
throws
InvalidArgumentException for invalid comparison operator

renderWherePart()

private function renderWherePart(array $part, bool $first = false): string

Renders a WHERE part. Like: `AND column IN('value1', 'value2')`.

Parameters
  • array $part - Keys: `glue`, `operator`, `column` and `values`
  • bool $first - Is the first part? Prepends the operator (`AND` or `OR`)
Returns string

renderWhereValues()

private function renderWhereValues(string $operator, array $values): ?string

Renders the values used by a comparison operator.

Parameters
  • string $operator - `=`, `<=>`, `!=`, `<>`, `>`, `>=`, `<`, `<=`, `LIKE`, `NOT LIKE`, `IN`, `NOT IN`, `BETWEEN`, `NOT BETWEEN`, `IS NULL` or `IS NOT NULL`
  • array $values
Returns ?string - The values used by the operator
throws
InvalidArgumentException for invalid comparison operator

renderWhereValuesPartBetween()

private function renderWhereValuesPartBetween(string $operator, array $values): string

Renders values for `BETWEEN` or `NOT BETWEEN`.

Parameters
  • string $operator - `BETWEEN` or `NOT BETWEEN`
  • array $values - Two values, indexes 0 and 1
Returns string
throws
InvalidArgumentException if $values not receive exactly two values

renderWhereValuesPartComparator()

private function renderWhereValuesPartComparator(string $operator, array $values): string

Renders the values of operators that receive exactly one value.

Parameters
  • string $operator - `=`, `<=>`, `!=`, `<>`, `>`, `>=`, `<`, `<=`, `LIKE` or `NOT LIKE`
  • array $values - Must receive exactly 1 value, index 0
Returns string
throws
InvalidArgumentException if $values has more than one value

renderWhereValuesPartIn()

private function renderWhereValuesPartIn(string $operator, array $values): string

Implode values for `IN` or `NOT IN`.

Parameters
  • string $operator - `IN` or `NOT IN`
  • array $values - Must receive at least 1 value
Returns string
throws
InvalidArgumentException if $values does not receive any value

renderWhereValuesPartIsNull()

private function renderWhereValuesPartIsNull(string $operator, array $values)

Renders the lonely operators, `IS NULL` or `IS NOT NULL`.

Parameters
  • string $operator - `IS NULL` or `IS NOT NULL`
  • array $values - Must be an empty array
Returns null
throws
InvalidArgumentException if $values is not empty