interface Builder (View source)

Methods

select(array|mixed $columns = ['*'])

Set the columns to be selected.

selectSub(Closure|Builder|string $query, string $as)

Add a subselect expression to the query.

selectRaw(string $expression, array $bindings = [])

Add a new "raw" select expression to the query.

fromSub(Closure|Builder|string $query, string $as)

Makes "from" fetch from a subquery.

fromRaw(string $expression, mixed $bindings = [])

Add a raw from clause to the query.

addSelect(array|mixed $column)

Add a new select column to the query.

distinct()

Force the query to only return distinct results.

from(Closure|Builder|string $table, string|null $as = null)

Set the table which the query is targeting.

join(string $table, Closure|string $first, string|null $operator = null, string|null $second = null, string $type = 'inner', bool $where = false)

Add a join clause to the query.

joinWhere(string $table, Closure|string $first, string $operator, string $second, string $type = 'inner')

Add a "join where" clause to the query.

joinSub(Closure|Builder|string $query, string $as, Closure|string $first, string|null $operator = null, string|null $second = null, string $type = 'inner', bool $where = false)

Add a subquery join clause to the query.

leftJoin(string $table, Closure|string $first, string|null $operator = null, string|null $second = null)

Add a left join to the query.

leftJoinWhere(string $table, Closure|string $first, string $operator, string $second)

Add a "join where" clause to the query.

leftJoinSub(Closure|Builder|string $query, string $as, Closure|string $first, string|null $operator = null, string|null $second = null)

Add a subquery left join to the query.

rightJoin(string $table, Closure|string $first, string|null $operator = null, string|null $second = null)

Add a right join to the query.

rightJoinWhere(string $table, Closure|string $first, string $operator, string $second)

Add a "right join where" clause to the query.

rightJoinSub(Closure|Builder|string $query, string $as, Closure|string $first, string|null $operator = null, string|null $second = null)

Add a subquery right join to the query.

crossJoin(string $table, Closure|string|null $first = null, string|null $operator = null, string|null $second = null)

Add a "cross join" clause to the query.

crossJoinSub(Closure|Builder|string $query, string $as)

Add a subquery cross join to the query.

mergeWheres(array $wheres, array $bindings)

Merge an array of where clauses and bindings.

where(Closure|Builder|string|array $column, mixed $operator = null, mixed $value = null, string $boolean = 'and')

Add a basic where clause to the query.

array
prepareValueAndOperator(string $value, string $operator, bool $useDefault = false)

Prepare the value and operator for a where clause.

orWhere(Closure|Builder|string|array $column, mixed $operator = null, mixed $value = null)

Add an "or where" clause to the query.

whereColumn(string|array $first, string|null $operator = null, string|null $second = null, string|null $boolean = 'and')

Add a "where" clause comparing two columns to the query.

orWhereColumn(string|array $first, string|null $operator = null, string|null $second = null)

Add an "or where" clause comparing two columns to the query.

whereRaw(string $sql, mixed $bindings = [], string $boolean = 'and')

Add a raw where clause to the query.

orWhereRaw(string $sql, mixed $bindings = [])

Add a raw "or where" clause to the query.

whereIn(string $column, mixed $values, string $boolean = 'and', bool $not = false)

Add a "where in" clause to the query.

orWhereIn(string $column, mixed $values)

Add an "or where in" clause to the query.

whereNotIn(string $column, mixed $values, string $boolean = 'and')

Add a "where not in" clause to the query.

orWhereNotIn(string $column, mixed $values)

Add an "or where not in" clause to the query.

whereIntegerInRaw(string $column, Arrayable|array $values, string $boolean = 'and', bool $not = false)

Add a "where in raw" clause for integer values to the query.

orWhereIntegerInRaw(string $column, Arrayable|array $values)

Add an "or where in raw" clause for integer values to the query.

whereIntegerNotInRaw(string $column, Arrayable|array $values, string $boolean = 'and')

Add a "where not in raw" clause for integer values to the query.

orWhereIntegerNotInRaw(string $column, Arrayable|array $values)

Add an "or where not in raw" clause for integer values to the query.

whereNull(string|array $columns, string $boolean = 'and', bool $not = false)

Add a "where null" clause to the query.

orWhereNull(string|array $column)

Add an "or where null" clause to the query.

whereNotNull(string|array $columns, string $boolean = 'and')

Add a "where not null" clause to the query.

whereBetween(string|Expression $column, iterable $values, string $boolean = 'and', bool $not = false)

Add a where between statement to the query.

whereBetweenColumns(string $column, array $values, string $boolean = 'and', bool $not = false)

Add a where between statement using columns to the query.

orWhereBetween(string $column, iterable $values)

Add an or where between statement to the query.

orWhereBetweenColumns(string $column, array $values)

Add an or where between statement using columns to the query.

whereNotBetween(string $column, iterable $values, string $boolean = 'and')

Add a where not between statement to the query.

whereNotBetweenColumns(string $column, array $values, string $boolean = 'and')

Add a where not between statement using columns to the query.

orWhereNotBetween(string $column, iterable $values)

Add an or where not between statement to the query.

orWhereNotBetweenColumns(string $column, array $values)

Add an or where not between statement using columns to the query.

orWhereNotNull(string $column)

Add an "or where not null" clause to the query.

whereDate(string $column, string $operator, DateTimeInterface|string|null $value = null, string $boolean = 'and')

Add a "where date" statement to the query.

orWhereDate(string $column, string $operator, DateTimeInterface|string|null $value = null)

Add an "or where date" statement to the query.

whereTime(string $column, string $operator, DateTimeInterface|string|null $value = null, string $boolean = 'and')

Add a "where time" statement to the query.

orWhereTime(string $column, string $operator, DateTimeInterface|string|null $value = null)

Add an "or where time" statement to the query.

whereDay(string $column, string $operator, DateTimeInterface|string|null $value = null, string $boolean = 'and')

Add a "where day" statement to the query.

orWhereDay(string $column, string $operator, DateTimeInterface|string|null $value = null)

Add an "or where day" statement to the query.

whereMonth(string $column, string $operator, DateTimeInterface|string|null $value = null, string $boolean = 'and')

Add a "where month" statement to the query.

orWhereMonth(string $column, string $operator, DateTimeInterface|string|null $value = null)

Add an "or where month" statement to the query.

whereYear(string $column, string $operator, DateTimeInterface|string|int|null $value = null, string $boolean = 'and')

Add a "where year" statement to the query.

orWhereYear(string $column, string $operator, DateTimeInterface|string|int|null $value = null)

Add an "or where year" statement to the query.

whereNested(Closure $callback, string $boolean = 'and')

Add a nested where statement to the query.

addNestedWhereQuery(Builder $query, string $boolean = 'and')

Add another query builder as a nested where to the query builder.

whereExists(Closure $callback, string $boolean = 'and', bool $not = false)

Add an exists clause to the query.

orWhereExists(Closure $callback, bool $not = false)

Add an or exists clause to the query.

whereNotExists(Closure $callback, string $boolean = 'and')

Add a where not exists clause to the query.

orWhereNotExists(Closure $callback)

Add a where not exists clause to the query.

whereRowValues(array $columns, string $operator, array $values, string $boolean = 'and')

Adds a where condition using row values.

orWhereRowValues(array $columns, string $operator, array $values)

Adds an or where condition using row values.

whereJsonContains(string $column, mixed $value, string $boolean = 'and', bool $not = false)

Add a "where JSON contains" clause to the query.

orWhereJsonContains(string $column, mixed $value)

Add an "or where JSON contains" clause to the query.

whereJsonDoesntContain(string $column, mixed $value, string $boolean = 'and')

Add a "where JSON not contains" clause to the query.

orWhereJsonDoesntContain(string $column, mixed $value)

Add an "or where JSON not contains" clause to the query.

whereJsonLength(string $column, mixed $operator, mixed $value = null, string $boolean = 'and')

Add a "where JSON length" clause to the query.

orWhereJsonLength(string $column, mixed $operator, mixed $value = null)

Add an "or where JSON length" clause to the query.

groupBy(array|string ...$groups)

Add a "group by" clause to the query.

groupByRaw(string $sql, array $bindings = [])

Add a raw groupBy clause to the query.

having(string $column, string|null $operator = null, string|null $value = null, string $boolean = 'and')

Add a "having" clause to the query.

orHaving(string $column, string|null $operator = null, string|null $value = null)

Add an "or having" clause to the query.

havingNull(string|array $columns, string $boolean = 'and', bool $not = false)

Add a "having null" clause to the query.

orHavingNull(string $column)

Add an "or having null" clause to the query.

havingNotNull(string|array $columns, string $boolean = 'and')

Add a "having not null" clause to the query.

orHavingNotNull(string $column)

Add an "or having not null" clause to the query.

havingBetween(string $column, array $values, string $boolean = 'and', bool $not = false)

Add a "having between" clause to the query.

havingRaw(string $sql, array $bindings = [], string $boolean = 'and')

Add a raw having clause to the query.

orHavingRaw(string $sql, array $bindings = [])

Add a raw or having clause to the query.

orderBy(Closure|Expression|Builder|string $column, string $direction = 'asc')

Add an "order by" clause to the query.

orderByDesc(Closure|Expression|Builder|string $column)

Add a descending "order by" clause to the query.

latest(Closure|Expression|Builder|string $column = 'created_at')

Add an "order by" clause for a timestamp to the query.

oldest(Closure|Expression|Builder|string $column = 'created_at')

Add an "order by" clause for a timestamp to the query.

inRandomOrder(string $seed = '')

Put the query's results in random order.

orderByRaw(string $sql, array $bindings = [])

Add a raw "order by" clause to the query.

skip(int $value)

Alias to set the "offset" value of the query.

offset(int $value)

Set the "offset" value of the query.

take(int $value)

Alias to set the "limit" value of the query.

limit(int $value)

Set the "limit" value of the query.

forPage(int $page, int $perPage = 15)

Set the limit and offset for a given page.

forPageBeforeId(int $perPage = 15, int|null $lastId = 0, string $column = 'id')

Constrain the query to the previous "page" of results before a given ID.

forPageAfterId(int $perPage = 15, int|null $lastId = 0, string $column = 'id')

Constrain the query to the next "page" of results after a given ID.

reorder(string|null $column = null, string $direction = 'asc')

Remove all existing orders and optionally add a new order.

union(Builder|Closure $query, bool $all = false)

Add a union statement to the query.

unionAll(Builder|Closure $query)

Add a union all statement to the query.

lock(string|bool $value = true)

Lock the selected rows in the table.

lockForUpdate()

Lock the selected rows in the table for updating.

sharedLock()

Share lock the selected rows in the table.

newQuery()

Get a new instance of the query builder.

raw(mixed $value)

Create a raw database expression.

array
getBindings()

Get the current query value bindings in a flattened array.

array
getRawBindings()

Get the raw array of bindings.

setBindings(array $bindings, string $type = 'where')

Set the bindings on the query builder.

addBinding(mixed $value, string $type = 'where')

Add a binding to the query.

mergeBindings(Builder $query)

Merge an array of bindings into our bindings.

array
cleanBindings(array $bindings)

Remove all of the expressions from a list of bindings.

getConnection()

Get the database connection instance.

getProcessor()

Get the database query processor instance.

getGrammar()

Get the query grammar instance.

useWritePdo()

Use the write pdo for query.

clone()

Clone the query.

cloneWithout(array $properties)

Clone the query without the given properties.

cloneWithoutBindings(array $except)

Clone the query without the given bindings.

Details

Builder select(array|mixed $columns = ['*'])

Set the columns to be selected.

Parameters

array|mixed $columns

Return Value

Builder

Builder selectSub(Closure|Builder|string $query, string $as)

Add a subselect expression to the query.

Parameters

Closure|Builder|string $query
string $as

Return Value

Builder

Builder selectRaw(string $expression, array $bindings = [])

Add a new "raw" select expression to the query.

Parameters

string $expression
array $bindings

Return Value

Builder

Builder fromSub(Closure|Builder|string $query, string $as)

Makes "from" fetch from a subquery.

Parameters

Closure|Builder|string $query
string $as

Return Value

Builder

Builder fromRaw(string $expression, mixed $bindings = [])

Add a raw from clause to the query.

Parameters

string $expression
mixed $bindings

Return Value

Builder

Builder addSelect(array|mixed $column)

Add a new select column to the query.

Parameters

array|mixed $column

Return Value

Builder

Builder distinct()

Force the query to only return distinct results.

Return Value

Builder

Builder from(Closure|Builder|string $table, string|null $as = null)

Set the table which the query is targeting.

Parameters

Closure|Builder|string $table
string|null $as

Return Value

Builder

Builder join(string $table, Closure|string $first, string|null $operator = null, string|null $second = null, string $type = 'inner', bool $where = false)

Add a join clause to the query.

Parameters

string $table
Closure|string $first
string|null $operator
string|null $second
string $type
bool $where

Return Value

Builder

Builder joinWhere(string $table, Closure|string $first, string $operator, string $second, string $type = 'inner')

Add a "join where" clause to the query.

Parameters

string $table
Closure|string $first
string $operator
string $second
string $type

Return Value

Builder

Builder joinSub(Closure|Builder|string $query, string $as, Closure|string $first, string|null $operator = null, string|null $second = null, string $type = 'inner', bool $where = false)

Add a subquery join clause to the query.

Parameters

Closure|Builder|string $query
string $as
Closure|string $first
string|null $operator
string|null $second
string $type
bool $where

Return Value

Builder

Builder leftJoin(string $table, Closure|string $first, string|null $operator = null, string|null $second = null)

Add a left join to the query.

Parameters

string $table
Closure|string $first
string|null $operator
string|null $second

Return Value

Builder

Builder leftJoinWhere(string $table, Closure|string $first, string $operator, string $second)

Add a "join where" clause to the query.

Parameters

string $table
Closure|string $first
string $operator
string $second

Return Value

Builder

Builder leftJoinSub(Closure|Builder|string $query, string $as, Closure|string $first, string|null $operator = null, string|null $second = null)

Add a subquery left join to the query.

Parameters

Closure|Builder|string $query
string $as
Closure|string $first
string|null $operator
string|null $second

Return Value

Builder

Builder rightJoin(string $table, Closure|string $first, string|null $operator = null, string|null $second = null)

Add a right join to the query.

Parameters

string $table
Closure|string $first
string|null $operator
string|null $second

Return Value

Builder

Builder rightJoinWhere(string $table, Closure|string $first, string $operator, string $second)

Add a "right join where" clause to the query.

Parameters

string $table
Closure|string $first
string $operator
string $second

Return Value

Builder

Builder rightJoinSub(Closure|Builder|string $query, string $as, Closure|string $first, string|null $operator = null, string|null $second = null)

Add a subquery right join to the query.

Parameters

Closure|Builder|string $query
string $as
Closure|string $first
string|null $operator
string|null $second

Return Value

Builder

Builder crossJoin(string $table, Closure|string|null $first = null, string|null $operator = null, string|null $second = null)

Add a "cross join" clause to the query.

Parameters

string $table
Closure|string|null $first
string|null $operator
string|null $second

Return Value

Builder

Builder crossJoinSub(Closure|Builder|string $query, string $as)

Add a subquery cross join to the query.

Parameters

Closure|Builder|string $query
string $as

Return Value

Builder

Builder mergeWheres(array $wheres, array $bindings)

Merge an array of where clauses and bindings.

Parameters

array $wheres
array $bindings

Return Value

Builder

Builder where(Closure|Builder|string|array $column, mixed $operator = null, mixed $value = null, string $boolean = 'and')

Add a basic where clause to the query.

Parameters

Closure|Builder|string|array $column
mixed $operator
mixed $value
string $boolean

Return Value

Builder

array prepareValueAndOperator(string $value, string $operator, bool $useDefault = false)

Prepare the value and operator for a where clause.

Parameters

string $value
string $operator
bool $useDefault

Return Value

array

Builder orWhere(Closure|Builder|string|array $column, mixed $operator = null, mixed $value = null)

Add an "or where" clause to the query.

Parameters

Closure|Builder|string|array $column
mixed $operator
mixed $value

Return Value

Builder

Builder whereColumn(string|array $first, string|null $operator = null, string|null $second = null, string|null $boolean = 'and')

Add a "where" clause comparing two columns to the query.

Parameters

string|array $first
string|null $operator
string|null $second
string|null $boolean

Return Value

Builder

Builder orWhereColumn(string|array $first, string|null $operator = null, string|null $second = null)

Add an "or where" clause comparing two columns to the query.

Parameters

string|array $first
string|null $operator
string|null $second

Return Value

Builder

Builder whereRaw(string $sql, mixed $bindings = [], string $boolean = 'and')

Add a raw where clause to the query.

Parameters

string $sql
mixed $bindings
string $boolean

Return Value

Builder

Builder orWhereRaw(string $sql, mixed $bindings = [])

Add a raw "or where" clause to the query.

Parameters

string $sql
mixed $bindings

Return Value

Builder

Builder whereIn(string $column, mixed $values, string $boolean = 'and', bool $not = false)

Add a "where in" clause to the query.

Parameters

string $column
mixed $values
string $boolean
bool $not

Return Value

Builder

Builder orWhereIn(string $column, mixed $values)

Add an "or where in" clause to the query.

Parameters

string $column
mixed $values

Return Value

Builder

Builder whereNotIn(string $column, mixed $values, string $boolean = 'and')

Add a "where not in" clause to the query.

Parameters

string $column
mixed $values
string $boolean

Return Value

Builder

Builder orWhereNotIn(string $column, mixed $values)

Add an "or where not in" clause to the query.

Parameters

string $column
mixed $values

Return Value

Builder

Builder whereIntegerInRaw(string $column, Arrayable|array $values, string $boolean = 'and', bool $not = false)

Add a "where in raw" clause for integer values to the query.

Parameters

string $column
Arrayable|array $values
string $boolean
bool $not

Return Value

Builder

Builder orWhereIntegerInRaw(string $column, Arrayable|array $values)

Add an "or where in raw" clause for integer values to the query.

Parameters

string $column
Arrayable|array $values

Return Value

Builder

Builder whereIntegerNotInRaw(string $column, Arrayable|array $values, string $boolean = 'and')

Add a "where not in raw" clause for integer values to the query.

Parameters

string $column
Arrayable|array $values
string $boolean

Return Value

Builder

Builder orWhereIntegerNotInRaw(string $column, Arrayable|array $values)

Add an "or where not in raw" clause for integer values to the query.

Parameters

string $column
Arrayable|array $values

Return Value

Builder

Builder whereNull(string|array $columns, string $boolean = 'and', bool $not = false)

Add a "where null" clause to the query.

Parameters

string|array $columns
string $boolean
bool $not

Return Value

Builder

Builder orWhereNull(string|array $column)

Add an "or where null" clause to the query.

Parameters

string|array $column

Return Value

Builder

Builder whereNotNull(string|array $columns, string $boolean = 'and')

Add a "where not null" clause to the query.

Parameters

string|array $columns
string $boolean

Return Value

Builder

Builder whereBetween(string|Expression $column, iterable $values, string $boolean = 'and', bool $not = false)

Add a where between statement to the query.

Parameters

string|Expression $column
iterable $values
string $boolean
bool $not

Return Value

Builder

Builder whereBetweenColumns(string $column, array $values, string $boolean = 'and', bool $not = false)

Add a where between statement using columns to the query.

Parameters

string $column
array $values
string $boolean
bool $not

Return Value

Builder

Builder orWhereBetween(string $column, iterable $values)

Add an or where between statement to the query.

Parameters

string $column
iterable $values

Return Value

Builder

Builder orWhereBetweenColumns(string $column, array $values)

Add an or where between statement using columns to the query.

Parameters

string $column
array $values

Return Value

Builder

Builder whereNotBetween(string $column, iterable $values, string $boolean = 'and')

Add a where not between statement to the query.

Parameters

string $column
iterable $values
string $boolean

Return Value

Builder

Builder whereNotBetweenColumns(string $column, array $values, string $boolean = 'and')

Add a where not between statement using columns to the query.

Parameters

string $column
array $values
string $boolean

Return Value

Builder

Builder orWhereNotBetween(string $column, iterable $values)

Add an or where not between statement to the query.

Parameters

string $column
iterable $values

Return Value

Builder

Builder orWhereNotBetweenColumns(string $column, array $values)

Add an or where not between statement using columns to the query.

Parameters

string $column
array $values

Return Value

Builder

Builder orWhereNotNull(string $column)

Add an "or where not null" clause to the query.

Parameters

string $column

Return Value

Builder

Builder whereDate(string $column, string $operator, DateTimeInterface|string|null $value = null, string $boolean = 'and')

Add a "where date" statement to the query.

Parameters

string $column
string $operator
DateTimeInterface|string|null $value
string $boolean

Return Value

Builder

Builder orWhereDate(string $column, string $operator, DateTimeInterface|string|null $value = null)

Add an "or where date" statement to the query.

Parameters

string $column
string $operator
DateTimeInterface|string|null $value

Return Value

Builder

Builder whereTime(string $column, string $operator, DateTimeInterface|string|null $value = null, string $boolean = 'and')

Add a "where time" statement to the query.

Parameters

string $column
string $operator
DateTimeInterface|string|null $value
string $boolean

Return Value

Builder

Builder orWhereTime(string $column, string $operator, DateTimeInterface|string|null $value = null)

Add an "or where time" statement to the query.

Parameters

string $column
string $operator
DateTimeInterface|string|null $value

Return Value

Builder

Builder whereDay(string $column, string $operator, DateTimeInterface|string|null $value = null, string $boolean = 'and')

Add a "where day" statement to the query.

Parameters

string $column
string $operator
DateTimeInterface|string|null $value
string $boolean

Return Value

Builder

Builder orWhereDay(string $column, string $operator, DateTimeInterface|string|null $value = null)

Add an "or where day" statement to the query.

Parameters

string $column
string $operator
DateTimeInterface|string|null $value

Return Value

Builder

Builder whereMonth(string $column, string $operator, DateTimeInterface|string|null $value = null, string $boolean = 'and')

Add a "where month" statement to the query.

Parameters

string $column
string $operator
DateTimeInterface|string|null $value
string $boolean

Return Value

Builder

Builder orWhereMonth(string $column, string $operator, DateTimeInterface|string|null $value = null)

Add an "or where month" statement to the query.

Parameters

string $column
string $operator
DateTimeInterface|string|null $value

Return Value

Builder

Builder whereYear(string $column, string $operator, DateTimeInterface|string|int|null $value = null, string $boolean = 'and')

Add a "where year" statement to the query.

Parameters

string $column
string $operator
DateTimeInterface|string|int|null $value
string $boolean

Return Value

Builder

Builder orWhereYear(string $column, string $operator, DateTimeInterface|string|int|null $value = null)

Add an "or where year" statement to the query.

Parameters

string $column
string $operator
DateTimeInterface|string|int|null $value

Return Value

Builder

Builder whereNested(Closure $callback, string $boolean = 'and')

Add a nested where statement to the query.

Parameters

Closure $callback
string $boolean

Return Value

Builder

Builder addNestedWhereQuery(Builder $query, string $boolean = 'and')

Add another query builder as a nested where to the query builder.

Parameters

Builder $query
string $boolean

Return Value

Builder

Builder whereExists(Closure $callback, string $boolean = 'and', bool $not = false)

Add an exists clause to the query.

Parameters

Closure $callback
string $boolean
bool $not

Return Value

Builder

Builder orWhereExists(Closure $callback, bool $not = false)

Add an or exists clause to the query.

Parameters

Closure $callback
bool $not

Return Value

Builder

Builder whereNotExists(Closure $callback, string $boolean = 'and')

Add a where not exists clause to the query.

Parameters

Closure $callback
string $boolean

Return Value

Builder

Builder orWhereNotExists(Closure $callback)

Add a where not exists clause to the query.

Parameters

Closure $callback

Return Value

Builder

Builder whereRowValues(array $columns, string $operator, array $values, string $boolean = 'and')

Adds a where condition using row values.

Parameters

array $columns
string $operator
array $values
string $boolean

Return Value

Builder

Builder orWhereRowValues(array $columns, string $operator, array $values)

Adds an or where condition using row values.

Parameters

array $columns
string $operator
array $values

Return Value

Builder

Builder whereJsonContains(string $column, mixed $value, string $boolean = 'and', bool $not = false)

Add a "where JSON contains" clause to the query.

Parameters

string $column
mixed $value
string $boolean
bool $not

Return Value

Builder

Builder orWhereJsonContains(string $column, mixed $value)

Add an "or where JSON contains" clause to the query.

Parameters

string $column
mixed $value

Return Value

Builder

Builder whereJsonDoesntContain(string $column, mixed $value, string $boolean = 'and')

Add a "where JSON not contains" clause to the query.

Parameters

string $column
mixed $value
string $boolean

Return Value

Builder

Builder orWhereJsonDoesntContain(string $column, mixed $value)

Add an "or where JSON not contains" clause to the query.

Parameters

string $column
mixed $value

Return Value

Builder

Builder whereJsonLength(string $column, mixed $operator, mixed $value = null, string $boolean = 'and')

Add a "where JSON length" clause to the query.

Parameters

string $column
mixed $operator
mixed $value
string $boolean

Return Value

Builder

Builder orWhereJsonLength(string $column, mixed $operator, mixed $value = null)

Add an "or where JSON length" clause to the query.

Parameters

string $column
mixed $operator
mixed $value

Return Value

Builder

Builder groupBy(array|string ...$groups)

Add a "group by" clause to the query.

Parameters

array|string ...$groups

Return Value

Builder

Builder groupByRaw(string $sql, array $bindings = [])

Add a raw groupBy clause to the query.

Parameters

string $sql
array $bindings

Return Value

Builder

Builder having(string $column, string|null $operator = null, string|null $value = null, string $boolean = 'and')

Add a "having" clause to the query.

Parameters

string $column
string|null $operator
string|null $value
string $boolean

Return Value

Builder

Builder orHaving(string $column, string|null $operator = null, string|null $value = null)

Add an "or having" clause to the query.

Parameters

string $column
string|null $operator
string|null $value

Return Value

Builder

Builder havingNull(string|array $columns, string $boolean = 'and', bool $not = false)

Add a "having null" clause to the query.

Parameters

string|array $columns
string $boolean
bool $not

Return Value

Builder

Builder orHavingNull(string $column)

Add an "or having null" clause to the query.

Parameters

string $column

Return Value

Builder

Builder havingNotNull(string|array $columns, string $boolean = 'and')

Add a "having not null" clause to the query.

Parameters

string|array $columns
string $boolean

Return Value

Builder

Builder orHavingNotNull(string $column)

Add an "or having not null" clause to the query.

Parameters

string $column

Return Value

Builder

Builder havingBetween(string $column, array $values, string $boolean = 'and', bool $not = false)

Add a "having between" clause to the query.

Parameters

string $column
array $values
string $boolean
bool $not

Return Value

Builder

Builder havingRaw(string $sql, array $bindings = [], string $boolean = 'and')

Add a raw having clause to the query.

Parameters

string $sql
array $bindings
string $boolean

Return Value

Builder

Builder orHavingRaw(string $sql, array $bindings = [])

Add a raw or having clause to the query.

Parameters

string $sql
array $bindings

Return Value

Builder

Builder orderBy(Closure|Expression|Builder|string $column, string $direction = 'asc')

Add an "order by" clause to the query.

Parameters

Closure|Expression|Builder|string $column
string $direction

Return Value

Builder

Builder orderByDesc(Closure|Expression|Builder|string $column)

Add a descending "order by" clause to the query.

Parameters

Closure|Expression|Builder|string $column

Return Value

Builder

Builder latest(Closure|Expression|Builder|string $column = 'created_at')

Add an "order by" clause for a timestamp to the query.

Parameters

Closure|Expression|Builder|string $column

Return Value

Builder

Builder oldest(Closure|Expression|Builder|string $column = 'created_at')

Add an "order by" clause for a timestamp to the query.

Parameters

Closure|Expression|Builder|string $column

Return Value

Builder

Builder inRandomOrder(string $seed = '')

Put the query's results in random order.

Parameters

string $seed

Return Value

Builder

Builder orderByRaw(string $sql, array $bindings = [])

Add a raw "order by" clause to the query.

Parameters

string $sql
array $bindings

Return Value

Builder

Builder skip(int $value)

Alias to set the "offset" value of the query.

Parameters

int $value

Return Value

Builder

Builder offset(int $value)

Set the "offset" value of the query.

Parameters

int $value

Return Value

Builder

Builder take(int $value)

Alias to set the "limit" value of the query.

Parameters

int $value

Return Value

Builder

Builder limit(int $value)

Set the "limit" value of the query.

Parameters

int $value

Return Value

Builder

Builder forPage(int $page, int $perPage = 15)

Set the limit and offset for a given page.

Parameters

int $page
int $perPage

Return Value

Builder

Builder forPageBeforeId(int $perPage = 15, int|null $lastId = 0, string $column = 'id')

Constrain the query to the previous "page" of results before a given ID.

Parameters

int $perPage
int|null $lastId
string $column

Return Value

Builder

Builder forPageAfterId(int $perPage = 15, int|null $lastId = 0, string $column = 'id')

Constrain the query to the next "page" of results after a given ID.

Parameters

int $perPage
int|null $lastId
string $column

Return Value

Builder

Builder reorder(string|null $column = null, string $direction = 'asc')

Remove all existing orders and optionally add a new order.

Parameters

string|null $column
string $direction

Return Value

Builder

Builder union(Builder|Closure $query, bool $all = false)

Add a union statement to the query.

Parameters

Builder|Closure $query
bool $all

Return Value

Builder

Builder unionAll(Builder|Closure $query)

Add a union all statement to the query.

Parameters

Builder|Closure $query

Return Value

Builder

Builder lock(string|bool $value = true)

Lock the selected rows in the table.

Parameters

string|bool $value

Return Value

Builder

Builder lockForUpdate()

Lock the selected rows in the table for updating.

Return Value

Builder

Builder sharedLock()

Share lock the selected rows in the table.

Return Value

Builder

Builder newQuery()

Get a new instance of the query builder.

Return Value

Builder

Expression raw(mixed $value)

Create a raw database expression.

Parameters

mixed $value

Return Value

Expression

array getBindings()

Get the current query value bindings in a flattened array.

Return Value

array

array getRawBindings()

Get the raw array of bindings.

Return Value

array

Builder setBindings(array $bindings, string $type = 'where')

Set the bindings on the query builder.

Parameters

array $bindings
string $type

Return Value

Builder

Builder addBinding(mixed $value, string $type = 'where')

Add a binding to the query.

Parameters

mixed $value
string $type

Return Value

Builder

Builder mergeBindings(Builder $query)

Merge an array of bindings into our bindings.

Parameters

Builder $query

Return Value

Builder

array cleanBindings(array $bindings)

Remove all of the expressions from a list of bindings.

Parameters

array $bindings

Return Value

array

ConnectionInterface getConnection()

Get the database connection instance.

Return Value

ConnectionInterface

Processor getProcessor()

Get the database query processor instance.

Return Value

Processor

Grammar getGrammar()

Get the query grammar instance.

Return Value

Grammar

Builder useWritePdo()

Use the write pdo for query.

Return Value

Builder

Builder clone()

Clone the query.

Return Value

Builder

Builder cloneWithout(array $properties)

Clone the query without the given properties.

Parameters

array $properties

Return Value

Builder

Builder cloneWithoutBindings(array $except)

Clone the query without the given bindings.

Parameters

array $except

Return Value

Builder