class Illuminate / Database / Query / Builder

Builder

Implements

Uses

Properties

public

$connection ConnectionInterface

The database connection instance.

Default: null
public

$grammar Grammar

The database query grammar instance.

Default: null
public

$processor Processor

The database query post processor instance.

Default: null
public

$bindings array

The current query value bindings.

Default: array
public

$aggregate array

An aggregate function and column to be run.

Default: null
public

$columns array

The columns that should be returned.

Default: null
public

$distinct bool|array

Indicates if the query returns distinct results.

Occasionally contains the columns that should be distinct.

Default: false
public

$from string

The table which the query is targeting.

Default: null
public

$indexHint IndexHint

The index hint for the query.

Default: null
public

$joins array

The table joins for the query.

Default: null
public

$wheres array

The where constraints for the query.

Default: []
public

$groups array

The groupings for the query.

Default: null
public

$havings array

The having constraints for the query.

Default: null
public

$orders array

The orderings for the query.

Default: null
public

$limit int

The maximum number of records to return.

Default: null
public

$offset int

The number of records to skip.

Default: null
public

$unions array

The query union statements.

Default: null
public

$unionLimit int

The maximum number of union records to return.

Default: null
public

$unionOffset int

The number of union records to skip.

Default: null
public

$unionOrders array

The orderings for the union query.

Default: null
public

$lock string|bool

Indicates whether row locking is being used.

Default: null
public

$beforeQueryCallbacks array

The callbacks that should be invoked before the query is executed.

Default: []
public

$operators string[]

All of the available clause operators.

Default: array
public

$bitwiseOperators string[]

All of the available bitwise operators.

Default: array
public

$useWritePdo bool

Whether to use write pdo for the select.

Default: false

Methods

public

__construct ( ConnectionInterface $connection , Grammar $grammar , Processor $processor ) : void

Create a new query builder instance.

Parameters

public

select ( $columns ) : $this

Set the columns to be selected.

Parameters

  • $columns array|mixed
public

selectSub ( $query , $as ) : $this

Add a subselect expression to the query.

Parameters

public

selectRaw ( $expression , array $bindings ) : $this

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

Parameters

  • $expression string
  • $bindings array
public

fromSub ( $query , $as ) : $this

Makes "from" fetch from a subquery.

Parameters

public

fromRaw ( $expression , $bindings ) : $this

Add a raw from clause to the query.

Parameters

  • $expression string
  • $bindings mixed
protected

createSub ( $query ) : array

Creates a subquery and parse it.

Parameters

protected

parseSub ( $query ) : array

Parse the subquery into SQL and bindings.

Parameters

  • $query mixed
protected

prependDatabaseNameIfCrossDatabaseQuery ( $query ) : mixed

Prepend the database name if the given query is on another database.

Parameters

  • $query mixed
public

addSelect ( $column ) : $this

Add a new select column to the query.

Parameters

  • $column array|mixed
public

distinct ( ) : $this

Force the query to only return distinct results.

public

from ( $table , $as ) : $this

Set the table which the query is targeting.

Parameters

public

useIndex ( $index ) : $this

Add an index hint to suggest a query index.

Parameters

  • $index string
public

forceIndex ( $index ) : $this

Add an index hint to force a query index.

Parameters

  • $index string
public

ignoreIndex ( $index ) : $this

Add an index hint to ignore a query index.

Parameters

  • $index string
public

join ( $table , $first , $operator , $second , $type , $where ) : $this

Add a join clause to the query.

Parameters

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

joinWhere ( $table , $first , $operator , $second , $type ) : $this

Add a "join where" clause to the query.

Parameters

  • $table Expression |string
  • $first Closure |string
  • $operator string
  • $second string
  • $type string
public

joinSub ( $query , $as , $first , $operator , $second , $type , $where ) : $this

Add a subquery join clause to the query.

Parameters

public

leftJoin ( $table , $first , $operator , $second ) : $this

Add a left join to the query.

Parameters

public

leftJoinWhere ( $table , $first , $operator , $second ) : $this

Add a "join where" clause to the query.

Parameters

public

leftJoinSub ( $query , $as , $first , $operator , $second ) : $this

Add a subquery left join to the query.

Parameters

public

rightJoin ( $table , $first , $operator , $second ) : $this

Add a right join to the query.

Parameters

public

rightJoinWhere ( $table , $first , $operator , $second ) : $this

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

Parameters

public

rightJoinSub ( $query , $as , $first , $operator , $second ) : $this

Add a subquery right join to the query.

Parameters

public

crossJoin ( $table , $first , $operator , $second ) : $this

Add a "cross join" clause to the query.

Parameters

  • $table Expression |string
  • $first Closure |string|null
  • $operator string|null
  • $second string|null
public

crossJoinSub ( $query , $as ) : $this

Add a subquery cross join to the query.

Parameters

protected

newJoinClause ( $parentQuery , $type , $table ) : JoinClause

Get a new join clause.

Parameters

  • $parentQuery Builder
  • $type string
  • $table string
public

mergeWheres ( $wheres , $bindings ) : $this

Merge an array of where clauses and bindings.

Parameters

  • $wheres array
  • $bindings array
public

where ( $column , $operator , $value , $boolean ) : $this

Add a basic where clause to the query.

Parameters

protected

addArrayOfWheres ( $column , $boolean , $method ) : $this

Add an array of where clauses to the query.

Parameters

  • $column array
  • $boolean string
  • $method string
public

prepareValueAndOperator ( $value , $operator , $useDefault ) : array

Prepare the value and operator for a where clause.

Parameters

  • $value string
  • $operator string
  • $useDefault bool
protected

invalidOperatorAndValue ( $operator , $value ) : bool

Determine if the given operator and value combination is legal.

Parameters

  • $operator string
  • $value mixed
protected

invalidOperator ( $operator ) : bool

Determine if the given operator is supported.

Parameters

  • $operator string
protected

isBitwiseOperator ( $operator ) : bool

Determine if the operator is a bitwise operator.

Parameters

  • $operator string
public

orWhere ( $column , $operator , $value ) : $this

Add an "or where" clause to the query.

Parameters

public

whereNot ( $column , $operator , $value , $boolean ) : $this

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

Parameters

public

orWhereNot ( $column , $operator , $value ) : $this

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

Parameters

public

whereColumn ( $first , $operator , $second , $boolean ) : $this

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

Parameters

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

orWhereColumn ( $first , $operator , $second ) : $this

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

Parameters

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

whereRaw ( $sql , $bindings , $boolean ) : $this

Add a raw where clause to the query.

Parameters

  • $sql string
  • $bindings mixed
  • $boolean string
public

orWhereRaw ( $sql , $bindings ) : $this

Add a raw or where clause to the query.

Parameters

  • $sql string
  • $bindings mixed
public

whereIn ( $column , $values , $boolean , $not ) : $this

Add a "where in" clause to the query.

Parameters

  • $column Expression |string
  • $values mixed
  • $boolean string
  • $not bool
public

orWhereIn ( $column , $values ) : $this

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

Parameters

public

whereNotIn ( $column , $values , $boolean ) : $this

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

Parameters

  • $column Expression |string
  • $values mixed
  • $boolean string
public

orWhereNotIn ( $column , $values ) : $this

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

Parameters

public

whereIntegerInRaw ( $column , $values , $boolean , $not ) : $this

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

Parameters

  • $column string
  • $values Illuminate\...\Arrayable|array
  • $boolean string
  • $not bool
public

orWhereIntegerInRaw ( $column , $values ) : $this

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

Parameters

  • $column string
  • $values Illuminate\...\Arrayable|array
public

whereIntegerNotInRaw ( $column , $values , $boolean ) : $this

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

Parameters

  • $column string
  • $values Illuminate\...\Arrayable|array
  • $boolean string
public

orWhereIntegerNotInRaw ( $column , $values ) : $this

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

Parameters

  • $column string
  • $values Illuminate\...\Arrayable|array
public

whereNull ( $columns , $boolean , $not ) : $this

Add a "where null" clause to the query.

Parameters

  • $columns string|array|Expression
  • $boolean string
  • $not bool
public

orWhereNull ( $column ) : $this

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

Parameters

public

whereNotNull ( $columns , $boolean ) : $this

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

Parameters

public

whereBetween ( $column , iterable $values , $boolean , $not ) : $this

Add a where between statement to the query.

Parameters

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

whereBetweenColumns ( $column , array $values , $boolean , $not ) : $this

Add a where between statement using columns to the query.

Parameters

  • $column Expression |string
  • $values array
  • $boolean string
  • $not bool
public

orWhereBetween ( $column , iterable $values ) : $this

Add an or where between statement to the query.

Parameters

public

orWhereBetweenColumns ( $column , array $values ) : $this

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

Parameters

public

whereNotBetween ( $column , iterable $values , $boolean ) : $this

Add a where not between statement to the query.

Parameters

  • $column Expression |string
  • $values iterable
  • $boolean string
public

whereNotBetweenColumns ( $column , array $values , $boolean ) : $this

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

Parameters

  • $column Expression |string
  • $values array
  • $boolean string
public

orWhereNotBetween ( $column , iterable $values ) : $this

Add an or where not between statement to the query.

Parameters

public

orWhereNotBetweenColumns ( $column , array $values ) : $this

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

Parameters

public

orWhereNotNull ( $column ) : $this

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

Parameters

public

whereDate ( $column , $operator , $value , $boolean ) : $this

Add a "where date" statement to the query.

Parameters

public

orWhereDate ( $column , $operator , $value ) : $this

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

Parameters

public

whereTime ( $column , $operator , $value , $boolean ) : $this

Add a "where time" statement to the query.

Parameters

public

orWhereTime ( $column , $operator , $value ) : $this

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

Parameters

public

whereDay ( $column , $operator , $value , $boolean ) : $this

Add a "where day" statement to the query.

Parameters

public

orWhereDay ( $column , $operator , $value ) : $this

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

Parameters

public

whereMonth ( $column , $operator , $value , $boolean ) : $this

Add a "where month" statement to the query.

Parameters

public

orWhereMonth ( $column , $operator , $value ) : $this

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

Parameters

public

whereYear ( $column , $operator , $value , $boolean ) : $this

Add a "where year" statement to the query.

Parameters

public

orWhereYear ( $column , $operator , $value ) : $this

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

Parameters

protected

addDateBasedWhere ( $type , $column , $operator , $value , $boolean ) : $this

Add a date based (year, month, day, time) statement to the query.

Parameters

  • $type string
  • $column Expression |string
  • $operator string
  • $value mixed
  • $boolean string
public

whereNested ( Closure $callback , $boolean ) : $this

Add a nested where statement to the query.

Parameters

public

forNestedWhere ( ) : Builder

Create a new query instance for nested where condition.

public

addNestedWhereQuery ( $query , $boolean ) : $this

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

Parameters

protected

whereSub ( $column , $operator , Closure $callback , $boolean ) : $this

Add a full sub-select to the query.

Parameters

public

whereExists ( $callback , $boolean , $not ) : $this

Add an exists clause to the query.

Parameters

public

orWhereExists ( $callback , $not ) : $this

Add an or exists clause to the query.

Parameters

public

whereNotExists ( $callback , $boolean ) : $this

Add a where not exists clause to the query.

Parameters

public

orWhereNotExists ( $callback ) : $this

Add a where not exists clause to the query.

Parameters

public

addWhereExistsQuery ( $query , $boolean , $not ) : $this

Add an exists clause to the query.

Parameters

  • $query Builder
  • $boolean string
  • $not bool
public

whereRowValues ( $columns , $operator , $values , $boolean ) : $this

Adds a where condition using row values.

Parameters

  • $columns array
  • $operator string
  • $values array
  • $boolean string
public

orWhereRowValues ( $columns , $operator , $values ) : $this

Adds an or where condition using row values.

Parameters

  • $columns array
  • $operator string
  • $values array
public

whereJsonContains ( $column , $value , $boolean , $not ) : $this

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

Parameters

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

orWhereJsonContains ( $column , $value ) : $this

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

Parameters

  • $column string
  • $value mixed
public

whereJsonDoesntContain ( $column , $value , $boolean ) : $this

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

Parameters

  • $column string
  • $value mixed
  • $boolean string
public

orWhereJsonDoesntContain ( $column , $value ) : $this

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

Parameters

  • $column string
  • $value mixed
public

whereJsonContainsKey ( $column , $boolean , $not ) : $this

Add a clause that determines if a JSON path exists to the query.

Parameters

  • $column string
  • $boolean string
  • $not bool
public

orWhereJsonContainsKey ( $column ) : $this

Add an "or" clause that determines if a JSON path exists to the query.

Parameters

  • $column string
public

whereJsonDoesntContainKey ( $column , $boolean ) : $this

Add a clause that determines if a JSON path does not exist to the query.

Parameters

  • $column string
  • $boolean string
public

orWhereJsonDoesntContainKey ( $column ) : $this

Add an "or" clause that determines if a JSON path does not exist to the query.

Parameters

  • $column string
public

whereJsonLength ( $column , $operator , $value , $boolean ) : $this

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

Parameters

  • $column string
  • $operator mixed
  • $value mixed
  • $boolean string
public

orWhereJsonLength ( $column , $operator , $value ) : $this

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

Parameters

  • $column string
  • $operator mixed
  • $value mixed
public

dynamicWhere ( $method , $parameters ) : $this

Handles dynamic "where" clauses to the query.

Parameters

  • $method string
  • $parameters array
protected

addDynamic ( $segment , $connector , $parameters , $index ) : void

Add a single dynamic where clause statement to the query.

Parameters

  • $segment string
  • $connector string
  • $parameters array
  • $index int
public

whereFullText ( $columns , $value , array $options , $boolean ) : $this

Add a "where fulltext" clause to the query.

Parameters

  • $columns string|string[]
  • $value string
  • $boolean string
public

orWhereFullText ( $columns , $value , array $options ) : $this

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

Parameters

  • $columns string|string[]
  • $value string
public

groupBy ( $groups ) : $this

Add a "group by" clause to the query.

Parameters

public

groupByRaw ( $sql , array $bindings ) : $this

Add a raw groupBy clause to the query.

Parameters

  • $sql string
  • $bindings array
public

having ( $column , $operator , $value , $boolean ) : $this

Add a "having" clause to the query.

Parameters

  • $column Expression |Closure |string
  • $operator string|int|float|null
  • $value string|int|float|null
  • $boolean string
public

orHaving ( $column , $operator , $value ) : $this

Add an "or having" clause to the query.

Parameters

  • $column Expression |Closure |string
  • $operator string|int|float|null
  • $value string|int|float|null
public

havingNested ( Closure $callback , $boolean ) : $this

Add a nested having statement to the query.

Parameters

public

addNestedHavingQuery ( $query , $boolean ) : $this

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

Parameters

public

havingNull ( $columns , $boolean , $not ) : $this

Add a "having null" clause to the query.

Parameters

  • $columns string|array
  • $boolean string
  • $not bool
public

orHavingNull ( $column ) : $this

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

Parameters

  • $column string
public

havingNotNull ( $columns , $boolean ) : $this

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

Parameters

  • $columns string|array
  • $boolean string
public

orHavingNotNull ( $column ) : $this

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

Parameters

  • $column string
public

havingBetween ( $column , iterable $values , $boolean , $not ) : $this

Add a "having between " clause to the query.

Parameters

  • $column string
  • $values iterable
  • $boolean string
  • $not bool
public

havingRaw ( $sql , array $bindings , $boolean ) : $this

Add a raw having clause to the query.

Parameters

  • $sql string
  • $bindings array
  • $boolean string
public

orHavingRaw ( $sql , array $bindings ) : $this

Add a raw or having clause to the query.

Parameters

  • $sql string
  • $bindings array
public

orderBy ( $column , $direction ) : $this

Add an "order by" clause to the query.

Parameters

public

orderByDesc ( $column ) : $this

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

Parameters

public

latest ( $column ) : $this

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

Parameters

public

oldest ( $column ) : $this

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

Parameters

public

inRandomOrder ( $seed ) : $this

Put the query's results in random order.

Parameters

  • $seed string|int
public

orderByRaw ( $sql , $bindings ) : $this

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

Parameters

  • $sql string
  • $bindings array
public

skip ( $value ) : $this

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

Parameters

  • $value int
public

offset ( $value ) : $this

Set the "offset" value of the query.

Parameters

  • $value int
public

take ( $value ) : $this

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

Parameters

  • $value int
public

limit ( $value ) : $this

Set the "limit" value of the query.

Parameters

  • $value int
public

forPage ( $page , $perPage ) : $this

Set the limit and offset for a given page.

Parameters

  • $page int
  • $perPage int
public

forPageBeforeId ( $perPage , $lastId , $column ) : $this

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

Parameters

  • $perPage int
  • $lastId int|null
  • $column string
public

forPageAfterId ( $perPage , $lastId , $column ) : $this

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

Parameters

  • $perPage int
  • $lastId int|null
  • $column string
public

reorder ( $column , $direction ) : $this

Remove all existing orders and optionally add a new order.

Parameters

protected

removeExistingOrdersFor ( $column ) : array

Get an array with all orders with a given column removed.

Parameters

  • $column string
public

union ( $query , $all ) : $this

Add a union statement to the query.

Parameters

public

unionAll ( $query ) : $this

Add a union all statement to the query.

Parameters

public

lock ( $value ) : $this

Lock the selected rows in the table.

Parameters

  • $value string|bool
public

lockForUpdate ( ) : $this

Lock the selected rows in the table for updating.

public

sharedLock ( ) : $this

Share lock the selected rows in the table.

public

beforeQuery ( callable $callback ) : $this

Register a closure to be invoked before the query is executed.

Parameters

  • $callback callable
public

applyBeforeQueryCallbacks ( ) : void

Invoke the "before query" modification callbacks.

public

toSql ( ) : string

Get the SQL representation of the query.

public

toRawSql ( ) : string

Get the raw SQL representation of the query with embedded bindings.

public

find ( $id , $columns ) : mixed|static

Execute a query for a single record by ID.

Parameters

  • $id int|string
  • $columns array|string
public

findOr ( $id , $columns , Closure $callback ) : mixed|static

Execute a query for a single record by ID or call a callback.

Parameters

public

value ( $column ) : mixed

Get a single column's value from the first result of a query.

Parameters

  • $column string
public

rawValue ( string $expression , array $bindings ) : mixed

Get a single expression value from the first result of a query.

Parameters

  • $expression string
  • $bindings array
public

soleValue ( $column ) : mixed

Get a single column's value from the first result of a query if it's the sole matching record.

Parameters

  • $column string
public

get ( $columns ) : Illuminate\...\Collection

Execute the query as a "select" statement.

Parameters

  • $columns array|string
protected

runSelect ( ) : array

Run the query as a "select" statement against the connection.

public

paginate ( $perPage , $columns , $pageName , $page ) : LengthAwarePaginator

Paginate the given query into a simple paginator.

Parameters

  • $perPage int|Closure
  • $columns array|string
  • $pageName string
  • $page int|null
  • $total Closure |int|null
public

simplePaginate ( $perPage , $columns , $pageName , $page ) : Paginator

Get a paginator only supporting simple next and previous links.

Parameters

  • $perPage int
  • $columns array|string
  • $pageName string
  • $page int|null
public

cursorPaginate ( $perPage , $columns , $cursorName , $cursor ) : CursorPaginator

Get a paginator only supporting simple next and previous links.

Parameters

  • $perPage int|null
  • $columns array|string
  • $cursorName string
  • $cursor Cursor |string|null
protected

ensureOrderForCursorPagination ( $shouldReverse ) : Illuminate\...\Collection

Ensure the proper order by required for cursor pagination.

Parameters

  • $shouldReverse bool
public

getCountForPagination ( $columns ) : int

Get the count of the total records for the paginator.

Parameters

  • $columns array
protected

runPaginationCountQuery ( $columns ) : array

Run a pagination count query.

Parameters

  • $columns array
protected

cloneForPaginationCount ( ) : self

Clone the existing query instance for usage in a pagination subquery.

protected

withoutSelectAliases ( array $columns ) : array

Remove the column aliases since they will break count queries.

Parameters

  • $columns array
public

cursor ( ) : Illuminate\...\LazyCollection

Get a lazy collection for the given query.

protected

enforceOrderBy ( ) : void

Throw an exception if the query doesn't have an orderBy clause.

public

pluck ( $column , $key ) : Illuminate\...\Collection

Get a collection instance containing the values of a given column.

Parameters

protected

stripTableForPluck ( $column ) : string|null

Strip off the table name or alias from a column identifier.

Parameters

  • $column string
protected

pluckFromObjectColumn ( $queryResult , $column , $key ) : Illuminate\...\Collection

Retrieve column values from rows represented as objects.

Parameters

  • $queryResult array
  • $column string
  • $key string
protected

pluckFromArrayColumn ( $queryResult , $column , $key ) : Illuminate\...\Collection

Retrieve column values from rows represented as arrays.

Parameters

  • $queryResult array
  • $column string
  • $key string
public

implode ( $column , $glue ) : string

Concatenate values of a given column as a string.

Parameters

  • $column string
  • $glue string
public

exists ( ) : bool

Determine if any rows exist for the current query.

public

doesntExist ( ) : bool

Determine if no rows exist for the current query.

public

existsOr ( Closure $callback ) : mixed

Execute the given callback if no rows exist for the current query.

Parameters

public

doesntExistOr ( Closure $callback ) : mixed

Execute the given callback if rows exist for the current query.

Parameters

public

count ( $columns ) : int

Retrieve the "count" result of the query.

Parameters

public

min ( $column ) : mixed

Retrieve the minimum value of a given column.

Parameters

public

max ( $column ) : mixed

Retrieve the maximum value of a given column.

Parameters

public

sum ( $column ) : mixed

Retrieve the sum of the values of a given column.

Parameters

public

avg ( $column ) : mixed

Retrieve the average of the values of a given column.

Parameters

public

average ( $column ) : mixed

Alias for the "avg" method.

Parameters

public

aggregate ( $function , $columns ) : mixed

Execute an aggregate function on the database.

Parameters

  • $function string
  • $columns array
public

numericAggregate ( $function , $columns ) : float|int

Execute a numeric aggregate function on the database.

Parameters

  • $function string
  • $columns array
protected

setAggregate ( $function , $columns ) : $this

Set the aggregate property without running the query.

Parameters

  • $function string
  • $columns array
protected

onceWithColumns ( $columns , $callback ) : mixed

Execute the given callback while selecting the given columns.

Parameters

  • $columns array
  • $callback callable
public

insert ( array $values ) : bool

Insert new records into the database.

Parameters

  • $values array
public

insertOrIgnore ( array $values ) : int

Insert new records into the database while ignoring errors.

Parameters

  • $values array
public

insertGetId ( array $values , $sequence ) : int

Insert a new record and get the value of the primary key.

Parameters

  • $values array
  • $sequence string|null
public

insertUsing ( array $columns , $query ) : int

Insert new records into the table using a subquery.

Parameters

public

update ( array $values ) : int

Update records in the database.

Parameters

  • $values array
public

updateFrom ( array $values ) : int

Update records in a PostgreSQL database using the update from syntax.

Parameters

  • $values array
public

updateOrInsert ( array $attributes , array $values ) : bool

Insert or update a record matching the attributes, and fill it with values.

Parameters

  • $attributes array
  • $values array
public

upsert ( array $values , $uniqueBy , $update ) : int

Insert new records or update the existing ones.

Parameters

  • $values array
  • $uniqueBy array|string
  • $update array|null
public

increment ( $column , $amount , array $extra ) : int

Increment a column's value by a given amount.

Parameters

  • $column string
  • $amount float|int
  • $extra array
public

incrementEach ( array $columns , array $extra ) : int

Increment the given column's values by the given amounts.

Parameters

  • $columns array|int|numeric-string>
  • $extra array
public

decrement ( $column , $amount , array $extra ) : int

Decrement a column's value by a given amount.

Parameters

  • $column string
  • $amount float|int
  • $extra array
public

decrementEach ( array $columns , array $extra ) : int

Decrement the given column's values by the given amounts.

Parameters

  • $columns array|int|numeric-string>
  • $extra array
public

delete ( $id ) : int

Delete records from the database.

Parameters

  • $id mixed
public

truncate ( ) : void

Run a truncate statement on the table.

public

newQuery ( ) : Builder

Get a new instance of the query builder.

protected

forSubQuery ( ) : Builder

Create a new query instance for a sub-query.

public

getColumns ( ) : array

Get all of the query builder's columns in a text-only array with all expressions evaluated.

public

raw ( $value ) : Expression

Create a raw database expression.

Parameters

  • $value mixed
public

getBindings ( ) : array

Get the current query value bindings in a flattened array.

public

getRawBindings ( ) : array

Get the raw array of bindings.

public

setBindings ( array $bindings , $type ) : $this

Set the bindings on the query builder.

Parameters

  • $bindings array
  • $type string
public

addBinding ( $value , $type ) : $this

Add a binding to the query.

Parameters

  • $value mixed
  • $type string
public

castBinding ( $value ) : mixed

Cast the given binding value.

Parameters

  • $value mixed
public

mergeBindings ( $query ) : $this

Merge an array of bindings into our bindings.

Parameters

public

cleanBindings ( array $bindings ) : array

Remove all of the expressions from a list of bindings.

Parameters

  • $bindings array
protected

flattenValue ( $value ) : mixed

Get a scalar type value from an unknown type of input.

Parameters

  • $value mixed
protected

defaultKeyName ( ) : string

Get the default key name of the table.

public

getConnection ( ) : ConnectionInterface

Get the database connection instance.

public

getProcessor ( ) : Processor

Get the database query processor instance.

public

getGrammar ( ) : Grammar

Get the query grammar instance.

public

useWritePdo ( ) : $this

Use the "write" PDO connection when executing the query.

protected

isQueryable ( $value ) : bool

Determine if the value is a query builder instance or a Closure.

Parameters

  • $value mixed
public

clone ( ) : static

Clone the query.

public

cloneWithout ( array $properties ) : static

Clone the query without the given properties.

Parameters

  • $properties array
public

cloneWithoutBindings ( array $except ) : static

Clone the query without the given bindings.

Parameters

  • $except array
public

dump ( ) : $this

Dump the current SQL and bindings.

public

dumpRawSql ( ) : $this

Dump the raw current SQL with embedded bindings.

public

dd ( ) : never

Die and dump the current SQL and bindings.

public

ddRawSql ( ) : never

Die and dump the current SQL with embedded bindings.

public

__call ( $method , $parameters ) : mixed

Handle dynamic method calls into the method.

Parameters

  • $method string
  • $parameters array