QueryBuilder
final class QueryBuilder (View source)
Builds immutable SQL query descriptions with validated structured clauses and explicit raw SQL boundaries.
Structured identifiers are validated before driver quoting, and caller values are retained as bindings.
Constants
| private JOIN_TYPES |
|
| private JOIN_OPERATORS |
|
Methods
Builds the requested database value while preserving its framework contract.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Builds the requested database value while preserving its framework contract.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Builds the requested database value while preserving its framework contract.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Appends a backward-compatible JOIN whose ON condition is trusted raw SQL.
Appends a JOIN with validated table, type, column identifiers, and comparison operator.
Appends an explicitly trusted raw ON condition while binding all caller-supplied values separately.
Appends a compiled subquery with a trusted raw ON condition and preserves all placeholder bindings.
Appends a compiled subquery using a structured comparison of two validated column identifiers.
Appends a compiled subquery with an explicitly trusted raw ON fragment and ordered value bindings.
Appends a LEFT JOIN subquery with a backward-compatible trusted raw ON condition.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Retrieves the requested value without changing the current database state.
Reports whether the requested condition holds for the current database state.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Requests an exclusive row lock when the query is evaluated inside a transaction.
Requests a shared row lock when the query is evaluated inside a transaction.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Details
make
static QueryBuilder
make(DatabaseDriverInterface $db)
Builds the requested database value while preserving its framework contract.
table
QueryBuilder
table(string $table)
Provides this part of the database contract while preserving the object's current state and driver semantics.
from
QueryBuilder
from(string $table)
Builds the requested database value while preserving its framework contract.
selectSubquery
QueryBuilder
selectSubquery(QueryBuilder $query, string $alias)
Provides this part of the database contract while preserving the object's current state and driver semantics.
fromSubquery
QueryBuilder
fromSubquery(QueryBuilder $query, string $alias)
Builds the requested database value while preserving its framework contract.
distinct
QueryBuilder
distinct(bool $state = true)
Provides this part of the database contract while preserving the object's current state and driver semantics.
join
QueryBuilder
join(string $table, string $condition, string $type = 'INNER', array $bindings = [])
Appends a backward-compatible JOIN whose ON condition is trusted raw SQL.
The table identifier and JOIN type are validated, but the condition is intentionally not parsed or escaped. Never concatenate untrusted values into it; pass values through the trailing bindings argument. Prefer joinOn() for a structured column comparison or joinRaw() when the raw boundary should be explicit.
joinOn
QueryBuilder
joinOn(string $table, string $leftColumn, string $operator, string $rightColumn, string $type = 'INNER')
Appends a JOIN with validated table, type, column identifiers, and comparison operator.
joinRaw
QueryBuilder
joinRaw(string $table, string $condition, array $bindings = [], string $type = 'INNER')
Appends an explicitly trusted raw ON condition while binding all caller-supplied values separately.
The raw condition is not parsed or escaped. Its SQL structure must be application-owned, while untrusted values belong in placeholders represented by the bindings list.
joinSubquery
QueryBuilder
joinSubquery(QueryBuilder $query, string $alias, string $condition, string $type = 'INNER', array $conditionBindings = [])
Appends a compiled subquery with a trusted raw ON condition and preserves all placeholder bindings.
The alias and JOIN type are validated. The condition remains raw for backward compatibility and must contain only application-owned SQL; caller values belong in the trailing bindings argument.
joinSubqueryOn
QueryBuilder
joinSubqueryOn(QueryBuilder $query, string $alias, string $leftColumn, string $operator, string $rightColumn, string $type = 'INNER')
Appends a compiled subquery using a structured comparison of two validated column identifiers.
joinSubqueryRaw
QueryBuilder
joinSubqueryRaw(QueryBuilder $query, string $alias, string $condition, array $bindings = [], string $type = 'INNER')
Appends a compiled subquery with an explicitly trusted raw ON fragment and ordered value bindings.
leftJoinSubquery
QueryBuilder
leftJoinSubquery(QueryBuilder $query, string $alias, string $condition, array $conditionBindings = [])
Appends a LEFT JOIN subquery with a backward-compatible trusted raw ON condition.
where_like
QueryBuilder
where_like(string $column, string $value, string $side = 'both')
Provides this part of the database contract while preserving the object's current state and driver semantics.
whereLike
QueryBuilder
whereLike(string $column, string $value, string $side = 'both')
Provides this part of the database contract while preserving the object's current state and driver semantics.
or_where_like
QueryBuilder
or_where_like(string $column, string $value, string $side = 'both')
Provides this part of the database contract while preserving the object's current state and driver semantics.
orWhereLike
QueryBuilder
orWhereLike(string $column, string $value, string $side = 'both')
Provides this part of the database contract while preserving the object's current state and driver semantics.
where_not_like
QueryBuilder
where_not_like(string $column, string $value, string $side = 'both')
Provides this part of the database contract while preserving the object's current state and driver semantics.
whereNotLike
QueryBuilder
whereNotLike(string $column, string $value, string $side = 'both')
Provides this part of the database contract while preserving the object's current state and driver semantics.
or_where_not_like
QueryBuilder
or_where_not_like(string $column, string $value, string $side = 'both')
Provides this part of the database contract while preserving the object's current state and driver semantics.
orWhereNotLike
QueryBuilder
orWhereNotLike(string $column, string $value, string $side = 'both')
Provides this part of the database contract while preserving the object's current state and driver semantics.
whereInSubquery
QueryBuilder
whereInSubquery(string $column, QueryBuilder $query)
Provides this part of the database contract while preserving the object's current state and driver semantics.
whereNotInSubquery
QueryBuilder
whereNotInSubquery(string $column, QueryBuilder $query)
Provides this part of the database contract while preserving the object's current state and driver semantics.
orWhereInSubquery
QueryBuilder
orWhereInSubquery(string $column, QueryBuilder $query)
Provides this part of the database contract while preserving the object's current state and driver semantics.
orWhereNotInSubquery
QueryBuilder
orWhereNotInSubquery(string $column, QueryBuilder $query)
Provides this part of the database contract while preserving the object's current state and driver semantics.
where_null
QueryBuilder
where_null(string $column)
Provides this part of the database contract while preserving the object's current state and driver semantics.
whereNull
QueryBuilder
whereNull(string $column)
Provides this part of the database contract while preserving the object's current state and driver semantics.
where_not_null
QueryBuilder
where_not_null(string $column)
Provides this part of the database contract while preserving the object's current state and driver semantics.
whereNotNull
QueryBuilder
whereNotNull(string $column)
Provides this part of the database contract while preserving the object's current state and driver semantics.
or_where_null
QueryBuilder
or_where_null(string $column)
Provides this part of the database contract while preserving the object's current state and driver semantics.
orWhereNull
QueryBuilder
orWhereNull(string $column)
Provides this part of the database contract while preserving the object's current state and driver semantics.
or_where_not_null
QueryBuilder
or_where_not_null(string $column)
Provides this part of the database contract while preserving the object's current state and driver semantics.
orWhereNotNull
QueryBuilder
orWhereNotNull(string $column)
Provides this part of the database contract while preserving the object's current state and driver semantics.
where_between
QueryBuilder
where_between(string $column, mixed $from, mixed $to)
Provides this part of the database contract while preserving the object's current state and driver semantics.
whereBetween
QueryBuilder
whereBetween(string $column, mixed $from, mixed $to)
Provides this part of the database contract while preserving the object's current state and driver semantics.
where_not_between
QueryBuilder
where_not_between(string $column, mixed $from, mixed $to)
Provides this part of the database contract while preserving the object's current state and driver semantics.
whereNotBetween
QueryBuilder
whereNotBetween(string $column, mixed $from, mixed $to)
Provides this part of the database contract while preserving the object's current state and driver semantics.
or_where_between
QueryBuilder
or_where_between(string $column, mixed $from, mixed $to)
Provides this part of the database contract while preserving the object's current state and driver semantics.
orWhereBetween
QueryBuilder
orWhereBetween(string $column, mixed $from, mixed $to)
Provides this part of the database contract while preserving the object's current state and driver semantics.
or_where_not_between
QueryBuilder
or_where_not_between(string $column, mixed $from, mixed $to)
Provides this part of the database contract while preserving the object's current state and driver semantics.
orWhereNotBetween
QueryBuilder
orWhereNotBetween(string $column, mixed $from, mixed $to)
Provides this part of the database contract while preserving the object's current state and driver semantics.
order_by
QueryBuilder
order_by(string $column, string $direction = 'ASC')
Provides this part of the database contract while preserving the object's current state and driver semantics.
orderBy
QueryBuilder
orderBy(string $column, string $direction = 'ASC')
Provides this part of the database contract while preserving the object's current state and driver semantics.
havingBetween
QueryBuilder
havingBetween(string $column, mixed $from, mixed $to)
Provides this part of the database contract while preserving the object's current state and driver semantics.
orHavingBetween
QueryBuilder
orHavingBetween(string $column, mixed $from, mixed $to)
Provides this part of the database contract while preserving the object's current state and driver semantics.
havingNotBetween
QueryBuilder
havingNotBetween(string $column, mixed $from, mixed $to)
Provides this part of the database contract while preserving the object's current state and driver semantics.
orHavingNotBetween
QueryBuilder
orHavingNotBetween(string $column, mixed $from, mixed $to)
Provides this part of the database contract while preserving the object's current state and driver semantics.
limit
QueryBuilder
limit(int $limit, int $offset = 0)
Provides this part of the database contract while preserving the object's current state and driver semantics.
offset
QueryBuilder
offset(int $offset)
Provides this part of the database contract while preserving the object's current state and driver semantics.
union
QueryBuilder
union(QueryBuilder $query)
Provides this part of the database contract while preserving the object's current state and driver semantics.
unionAll
QueryBuilder
unionAll(QueryBuilder $query)
Provides this part of the database contract while preserving the object's current state and driver semantics.
get
DatabaseResultInterface|bool
get(int|null $limit = null, int $offset = 0)
Retrieves the requested value without changing the current database state.
getArray
array
getArray(int|null $limit = null, int $offset = 0)
No description
exists
bool
exists()
Reports whether the requested condition holds for the current database state.
doesntExist
bool
doesntExist()
Provides this part of the database contract while preserving the object's current state and driver semantics.
value
mixed
value(string $column)
Provides this part of the database contract while preserving the object's current state and driver semantics.
pluck
array
pluck(string $column, string|null $key = null)
No description
lockForUpdate
QueryBuilder
lockForUpdate()
Requests an exclusive row lock when the query is evaluated inside a transaction.
sharedLock
QueryBuilder
sharedLock()
Requests a shared row lock when the query is evaluated inside a transaction.
first
array|null
first()
No description
count_all_results
int
count_all_results()
Provides this part of the database contract while preserving the object's current state and driver semantics.
countAllResults
int
countAllResults()
Provides this part of the database contract while preserving the object's current state and driver semantics.
insert
bool
insert(array|null $data = null)
No description
batch_insert
bool
batch_insert(array $rows)
No description
batchInsert
bool
batchInsert(array $rows)
No description
insertOrIgnore
bool
insertOrIgnore(array $rows)
No description
upsert
bool
upsert(array $rows, array $updateColumns = [])
No description
update
bool
update(array|null $data = null)
No description
increment
bool
increment(string $column, int|float $amount = 1)
Provides this part of the database contract while preserving the object's current state and driver semantics.
decrement
bool
decrement(string $column, int|float $amount = 1)
Provides this part of the database contract while preserving the object's current state and driver semantics.
batch_update
bool
batch_update(array $rows, string $index)
No description
batchUpdate
bool
batchUpdate(array $rows, string $index)
No description
delete
bool
delete(array $where = [])
No description