PHP Class Illuminate\Database\Query\Builder

Exibir arquivo Open project: illuminate/database Class Usage Examples

Public Properties

Property Type Description
$aggregate array An aggregate function and column to be run.
$columns array The columns that should be returned.
$distinct boolean Indicates if the query returns distinct results.
$from string The table which the query is targeting.
$groups array The groupings for the query.
$havings array The having constraints for the query.
$joins array The table joins for the query.
$limit integer The maximum number of records to return.
$lock string | boolean Indicates whether row locking is being used.
$offset integer The number of records to skip.
$orders array The orderings for the query.
$unionLimit integer The maximum number of union records to return.
$unionOffset integer The number of union records to skip.
$unionOrders array The orderings for the union query.
$unions array The query union statements.
$wheres array The where constraints for the query.

Protected Properties

Property Type Description
$backups array The field backups currently in use.
$bindingBackups array The binding backups currently in use.
$bindings array The current query value bindings.
$connection Illuminate\Database\Connection The database connection instance.
$grammar Illuminate\Database\Query\Grammars\Grammar The database query grammar instance.
$operators array All of the available clause operators.
$processor Illuminate\Database\Query\Processors\Processor The database query post processor instance.
$useWritePdo boolean Whether use write pdo for select.

Public Methods

Method Description
__call ( string $method, array $parameters ) : mixed Handle dynamic method calls into the method.
__construct ( Illuminate\Database\ConnectionInterface $connection, Illuminate\Database\Query\Grammars\Grammar $grammar = null, Illuminate\Database\Query\Processors\Processor $processor = null ) : void Create a new query builder instance.
addBinding ( mixed $value, string $type = 'where' ) Add a binding to the query.
addNestedWhereQuery ( Builder | static $query, string $boolean = 'and' ) Add another query builder as a nested where to the query builder.
addSelect ( array | mixed $column ) Add a new select column to the query.
addWhereExistsQuery ( Builder $query, string $boolean = 'and', boolean $not = false ) Add an exists clause to the query.
aggregate ( string $function, array $columns = ['*'] ) : mixed Execute an aggregate function on the database.
average ( string $column ) : mixed Alias for the "avg" method.
avg ( string $column ) : mixed Retrieve the average of the values of a given column.
chunk ( integer $count, callable $callback ) : boolean Chunk the results of the query.
chunkById ( integer $count, callable $callback, string $column = 'id', string $alias = null ) : boolean Chunk the results of a query by comparing numeric IDs.
count ( string $columns = '*' ) : integer Retrieve the "count" result of the query.
crossJoin ( string $table, string $first = null, string $operator = null, string $second = null ) : Builder | static Add a "cross join" clause to the query.
cursor ( ) : Generator Get a generator for the given query.
decrement ( string $column, integer $amount = 1, array $extra = [] ) : integer Decrement a column's value by a given amount.
delete ( mixed $id = null ) : integer Delete a record from the database.
distinct ( ) Force the query to only return distinct results.
dynamicWhere ( string $method, string $parameters ) Handles dynamic "where" clauses to the query.
each ( callable $callback, integer $count = 1000 ) : boolean Execute a callback over each item while chunking.
exists ( ) : boolean Determine if any rows exist for the current query.
find ( integer $id, array $columns = ['*'] ) : mixed | static Execute a query for a single record by ID.
first ( array $columns = ['*'] ) : stdClass | array | null Execute the query and get the first result.
forNestedWhere ( ) : Builder Create a new query instance for nested where condition.
forPage ( integer $page, integer $perPage = 15 ) : Builder | static Set the limit and offset for a given page.
forPageAfterId ( integer $perPage = 15, integer $lastId, string $column = 'id' ) : Builder | static Constrain the query to the next "page" of results after a given ID.
from ( string $table ) Set the table which the query is targeting.
get ( array $columns = ['*'] ) : Collection Execute the query as a "select" statement.
getBindings ( ) : array Get the current query value bindings in a flattened array.
getConnection ( ) : Illuminate\Database\ConnectionInterface Get the database connection instance.
getCountForPagination ( array $columns = ['*'] ) : integer Get the count of the total records for the paginator.
getGrammar ( ) : Illuminate\Database\Query\Grammars\Grammar Get the query grammar instance.
getProcessor ( ) : Illuminate\Database\Query\Processors\Processor Get the database query processor instance.
getRawBindings ( ) : array Get the raw array of bindings.
groupBy ( $groups ) Add a "group by" clause to the query.
having ( string $column, string $operator = null, string $value = null, string $boolean = 'and' ) Add a "having" clause to the query.
havingRaw ( string $sql, array $bindings = [], string $boolean = 'and' ) Add a raw having clause to the query.
implode ( string $column, string $glue = '' ) : string Concatenate values of a given column as a string.
inRandomOrder ( string $seed = '' ) Put the query's results in random order.
increment ( string $column, integer $amount = 1, array $extra = [] ) : integer Increment a column's value by a given amount.
insert ( array $values ) : boolean Insert a new record into the database.
insertGetId ( array $values, string $sequence = null ) : integer Insert a new record and get the value of the primary key.
join ( string $table, string $one, string $operator = null, string $two = null, string $type = 'inner', boolean $where = false ) Add a join clause to the query.
joinWhere ( string $table, string $one, string $operator, string $two, string $type = 'inner' ) : Builder | static Add a "join where" clause to the query.
latest ( string $column = 'created_at' ) : Builder | static Add an "order by" clause for a timestamp to the query.
leftJoin ( string $table, string $first, string $operator = null, string $second = null ) : Builder | static Add a left join to the query.
leftJoinWhere ( string $table, string $one, string $operator, string $two ) : Builder | static Add a "join where" clause to the query.
limit ( integer $value ) Set the "limit" value of the query.
lock ( boolean $value = true ) Lock the selected rows in the table.
lockForUpdate ( ) : Builder Lock the selected rows in the table for updating.
macroCall ( )
max ( string $column ) : mixed Retrieve the maximum value of a given column.
mergeBindings ( Builder $query ) Merge an array of bindings into our bindings.
mergeWheres ( array $wheres, array $bindings ) : void Merge an array of where clauses and bindings.
min ( string $column ) : mixed Retrieve the minimum value of a given column.
newQuery ( ) : Builder Get a new instance of the query builder.
numericAggregate ( string $function, array $columns = ['*'] ) : float | integer Execute a numeric aggregate function on the database.
offset ( integer $value ) Set the "offset" value of the query.
oldest ( string $column = 'created_at' ) : Builder | static Add an "order by" clause for a timestamp to the query.
orHaving ( string $column, string $operator = null, string $value = null ) : Builder | static Add a "or having" clause to the query.
orHavingRaw ( string $sql, array $bindings = [] ) : Builder | static Add a raw or having clause to the query.
orWhere ( Closure | string $column, string $operator = null, mixed $value = null ) : Builder | static Add an "or where" clause to the query.
orWhereBetween ( string $column, array $values ) : Builder | static Add an or where between statement to the query.
orWhereColumn ( string | array $first, string | null $operator = null, string | null $second = null ) : Builder | static Add an "or where" clause comparing two columns to the query.
orWhereDate ( string $column, string $operator, string $value ) : Builder | static Add an "or where date" statement to the query.
orWhereExists ( Closure $callback, boolean $not = false ) : Builder | static Add an or exists clause to the query.
orWhereIn ( string $column, mixed $values ) : Builder | static Add an "or where in" clause to the query.
orWhereNotBetween ( string $column, array $values ) : Builder | static Add an or where not between statement to the query.
orWhereNotExists ( Closure $callback ) : Builder | static Add a where not exists clause to the query.
orWhereNotIn ( string $column, mixed $values ) : Builder | static Add an "or where not in" clause to the query.
orWhereNotNull ( string $column ) : Builder | static Add an "or where not null" clause to the query.
orWhereNull ( string $column ) : Builder | static Add an "or where null" clause to the query.
orWhereRaw ( string $sql, array $bindings = [] ) : Builder | static Add a raw or where clause to the query.
orWhereTime ( string $column, string $operator, integer $value ) : Builder | static Add an "or where time" statement to the query.
orderBy ( string $column, string $direction = 'asc' ) Add an "order by" clause to the query.
orderByRaw ( string $sql, array $bindings = [] ) Add a raw "order by" clause to the query.
paginate ( integer $perPage = 15, array $columns = ['*'], string $pageName = 'page', integer | null $page = null ) : Illuminate\Contracts\Pagination\LengthAwarePaginator Paginate the given query into a simple paginator.
pluck ( string $column, string | null $key = null ) : Collection Get an array with the values of a given column.
raw ( mixed $value ) : Illuminate\Database\Query\Expression Create a raw database expression.
rightJoin ( string $table, string $first, string $operator = null, string $second = null ) : Builder | static Add a right join to the query.
rightJoinWhere ( string $table, string $one, string $operator, string $two ) : Builder | static Add a "right join where" clause to the query.
select ( array | mixed $columns = ['*'] ) Set the columns to be selected.
selectRaw ( string $expression, array $bindings = [] ) : Builder | static Add a new "raw" select expression to the query.
selectSub ( Closure | Builder | string $query, string $as ) : Builder | static Add a subselect expression to the query.
setBindings ( array $bindings, string $type = 'where' ) Set the bindings on the query builder.
sharedLock ( ) : Builder Share lock the selected rows in the table.
simplePaginate ( integer $perPage = 15, array $columns = ['*'], string $pageName = 'page', integer | null $page = null ) : Illuminate\Contracts\Pagination\Paginator Get a paginator only supporting simple next and previous links.
skip ( integer $value ) : Builder | static Alias to set the "offset" value of the query.
sum ( string $column ) : mixed Retrieve the sum of the values of a given column.
take ( integer $value ) : Builder | static Alias to set the "limit" value of the query.
toSql ( ) : string Get the SQL representation of the query.
truncate ( ) : void Run a truncate statement on the table.
union ( Builder | Closure $query, boolean $all = false ) : Builder | static Add a union statement to the query.
unionAll ( Builder | Closure $query ) : Builder | static Add a union all statement to the query.
update ( array $values ) : integer Update a record in the database.
updateOrInsert ( array $attributes, array $values = [] ) : boolean Insert or update a record matching the attributes, and fill it with values.
useWritePdo ( ) Use the write pdo for query.
value ( string $column ) : mixed Get a single column's value from the first result of a query.
when ( boolean $value, Closure $callback, Closure $default = null ) : Builder Apply the callback's query changes if the given "value" is true.
where ( string | array | Closure $column, string $operator = null, mixed $value = null, string $boolean = 'and' ) Add a basic where clause to the query.
whereBetween ( string $column, array $values, string $boolean = 'and', boolean $not = false ) Add a where between statement to the query.
whereColumn ( string | array $first, string | null $operator = null, string | null $second = null, string | null $boolean = 'and' ) : Builder | static Add a "where" clause comparing two columns to the query.
whereDate ( string $column, string $operator, mixed $value = null, string $boolean = 'and' ) : Builder | static Add a "where date" statement to the query.
whereDay ( string $column, string $operator, mixed $value = null, string $boolean = 'and' ) : Builder | static Add a "where day" statement to the query.
whereExists ( Closure $callback, string $boolean = 'and', boolean $not = false ) Add an exists clause to the query.
whereIn ( string $column, mixed $values, string $boolean = 'and', boolean $not = false ) Add a "where in" clause to the query.
whereMonth ( string $column, string $operator, mixed $value = null, string $boolean = 'and' ) : Builder | static Add a "where month" statement to the query.
whereNested ( Closure $callback, string $boolean = 'and' ) : Builder | static Add a nested where statement to the query.
whereNotBetween ( string $column, array $values, string $boolean = 'and' ) : Builder | static Add a where not between statement to the query.
whereNotExists ( Closure $callback, string $boolean = 'and' ) : Builder | static Add a where not exists clause to the query.
whereNotIn ( string $column, mixed $values, string $boolean = 'and' ) : Builder | static Add a "where not in" clause to the query.
whereNotNull ( string $column, string $boolean = 'and' ) : Builder | static Add a "where not null" clause to the query.
whereNull ( string $column, string $boolean = 'and', boolean $not = false ) Add a "where null" clause to the query.
whereRaw ( string $sql, mixed $bindings = [], string $boolean = 'and' ) Add a raw where clause to the query.
whereTime ( string $column, string $operator, integer $value, string $boolean = 'and' ) : Builder | static Add a "where time" statement to the query.
whereYear ( string $column, string $operator, mixed $value = null, string $boolean = 'and' ) : Builder | static Add a "where year" statement to the query.

Protected Methods

Method Description
addArrayOfWheres ( array $column, string $boolean, string $method = 'where' ) Add an array of where clauses to the query.
addDateBasedWhere ( string $type, string $column, string $operator, integer $value, string $boolean = 'and' ) Add a date based (year, month, day, time) statement to the query.
addDynamic ( string $segment, string $connector, array $parameters, integer $index ) : void Add a single dynamic where clause statement to the query.
backupFieldsForCount ( ) : void Backup then remove some fields for the pagination count.
cleanBindings ( array $bindings ) : array Remove all of the expressions from a list of bindings.
clearSelectAliases ( array $columns ) : array Remove the column aliases since they will break count queries.
enforceOrderBy ( ) : void Throw an exception if the query doesn't have an orderBy clause.
invalidOperatorAndValue ( string $operator, mixed $value ) : boolean Determine if the given operator and value combination is legal.
prepareValueAndOperator ( string $value, string $operator, boolean $useDefault = false ) : array Prepare the value and operator for a where clause.
restoreFieldsForCount ( ) : void Restore some fields after the pagination count.
runSelect ( ) : array Run the query as a "select" statement against the connection.
stripTableForPluck ( string $column ) : string | null Strip off the table name or alias from a column identifier.
whereInExistingQuery ( string $column, Builder | static $query, string $boolean, boolean $not ) Add an external sub-select to the query.
whereInSub ( string $column, Closure $callback, string $boolean, boolean $not ) Add a where in with a sub-select to the query.
whereSub ( string $column, string $operator, Closure $callback, string $boolean ) Add a full sub-select to the query.

Method Details

__call() public method

Handle dynamic method calls into the method.
public __call ( string $method, array $parameters ) : mixed
$method string
$parameters array
return mixed

__construct() public method

Create a new query builder instance.
public __construct ( Illuminate\Database\ConnectionInterface $connection, Illuminate\Database\Query\Grammars\Grammar $grammar = null, Illuminate\Database\Query\Processors\Processor $processor = null ) : void
$connection Illuminate\Database\ConnectionInterface
$grammar Illuminate\Database\Query\Grammars\Grammar
$processor Illuminate\Database\Query\Processors\Processor
return void

addArrayOfWheres() protected method

Add an array of where clauses to the query.
protected addArrayOfWheres ( array $column, string $boolean, string $method = 'where' )
$column array
$boolean string
$method string

addBinding() public method

Add a binding to the query.
public addBinding ( mixed $value, string $type = 'where' )
$value mixed
$type string

addDateBasedWhere() protected method

Add a date based (year, month, day, time) statement to the query.
protected addDateBasedWhere ( string $type, string $column, string $operator, integer $value, string $boolean = 'and' )
$type string
$column string
$operator string
$value integer
$boolean string

addDynamic() protected method

Add a single dynamic where clause statement to the query.
protected addDynamic ( string $segment, string $connector, array $parameters, integer $index ) : void
$segment string
$connector string
$parameters array
$index integer
return void

addNestedWhereQuery() public method

Add another query builder as a nested where to the query builder.
public addNestedWhereQuery ( Builder | static $query, string $boolean = 'and' )
$query Builder | static
$boolean string

addSelect() public method

Add a new select column to the query.
public addSelect ( array | mixed $column )
$column array | mixed

addWhereExistsQuery() public method

Add an exists clause to the query.
public addWhereExistsQuery ( Builder $query, string $boolean = 'and', boolean $not = false )
$query Builder
$boolean string
$not boolean

aggregate() public method

Execute an aggregate function on the database.
public aggregate ( string $function, array $columns = ['*'] ) : mixed
$function string
$columns array
return mixed

average() public method

Alias for the "avg" method.
public average ( string $column ) : mixed
$column string
return mixed

avg() public method

Retrieve the average of the values of a given column.
public avg ( string $column ) : mixed
$column string
return mixed

backupFieldsForCount() protected method

Backup then remove some fields for the pagination count.
protected backupFieldsForCount ( ) : void
return void

chunk() public method

Chunk the results of the query.
public chunk ( integer $count, callable $callback ) : boolean
$count integer
$callback callable
return boolean

chunkById() public method

Chunk the results of a query by comparing numeric IDs.
public chunkById ( integer $count, callable $callback, string $column = 'id', string $alias = null ) : boolean
$count integer
$callback callable
$column string
$alias string
return boolean

cleanBindings() protected method

Remove all of the expressions from a list of bindings.
protected cleanBindings ( array $bindings ) : array
$bindings array
return array

clearSelectAliases() protected method

Remove the column aliases since they will break count queries.
protected clearSelectAliases ( array $columns ) : array
$columns array
return array

count() public method

Retrieve the "count" result of the query.
public count ( string $columns = '*' ) : integer
$columns string
return integer

crossJoin() public method

Add a "cross join" clause to the query.
public crossJoin ( string $table, string $first = null, string $operator = null, string $second = null ) : Builder | static
$table string
$first string
$operator string
$second string
return Builder | static

cursor() public method

Get a generator for the given query.
public cursor ( ) : Generator
return Generator

decrement() public method

Decrement a column's value by a given amount.
public decrement ( string $column, integer $amount = 1, array $extra = [] ) : integer
$column string
$amount integer
$extra array
return integer

delete() public method

Delete a record from the database.
public delete ( mixed $id = null ) : integer
$id mixed
return integer

distinct() public method

Force the query to only return distinct results.
public distinct ( )

dynamicWhere() public method

Handles dynamic "where" clauses to the query.
public dynamicWhere ( string $method, string $parameters )
$method string
$parameters string

each() public method

Execute a callback over each item while chunking.
public each ( callable $callback, integer $count = 1000 ) : boolean
$callback callable
$count integer
return boolean

enforceOrderBy() protected method

Throw an exception if the query doesn't have an orderBy clause.
protected enforceOrderBy ( ) : void
return void

exists() public method

Determine if any rows exist for the current query.
public exists ( ) : boolean
return boolean

find() public method

Execute a query for a single record by ID.
public find ( integer $id, array $columns = ['*'] ) : mixed | static
$id integer
$columns array
return mixed | static

first() public method

Execute the query and get the first result.
public first ( array $columns = ['*'] ) : stdClass | array | null
$columns array
return stdClass | array | null

forNestedWhere() public method

Create a new query instance for nested where condition.
public forNestedWhere ( ) : Builder
return Builder

forPage() public method

Set the limit and offset for a given page.
public forPage ( integer $page, integer $perPage = 15 ) : Builder | static
$page integer
$perPage integer
return Builder | static

forPageAfterId() public method

Constrain the query to the next "page" of results after a given ID.
public forPageAfterId ( integer $perPage = 15, integer $lastId, string $column = 'id' ) : Builder | static
$perPage integer
$lastId integer
$column string
return Builder | static

from() public method

Set the table which the query is targeting.
public from ( string $table )
$table string

get() public method

Execute the query as a "select" statement.
public get ( array $columns = ['*'] ) : Collection
$columns array
return Illuminate\Support\Collection

getBindings() public method

Get the current query value bindings in a flattened array.
public getBindings ( ) : array
return array

getConnection() public method

Get the database connection instance.
public getConnection ( ) : Illuminate\Database\ConnectionInterface
return Illuminate\Database\ConnectionInterface

getCountForPagination() public method

Get the count of the total records for the paginator.
public getCountForPagination ( array $columns = ['*'] ) : integer
$columns array
return integer

getGrammar() public method

Get the query grammar instance.
public getGrammar ( ) : Illuminate\Database\Query\Grammars\Grammar
return Illuminate\Database\Query\Grammars\Grammar

getProcessor() public method

Get the database query processor instance.
public getProcessor ( ) : Illuminate\Database\Query\Processors\Processor
return Illuminate\Database\Query\Processors\Processor

getRawBindings() public method

Get the raw array of bindings.
public getRawBindings ( ) : array
return array

groupBy() public method

Add a "group by" clause to the query.
public groupBy ( $groups )
$groups

having() public method

Add a "having" clause to the query.
public having ( string $column, string $operator = null, string $value = null, string $boolean = 'and' )
$column string
$operator string
$value string
$boolean string

havingRaw() public method

Add a raw having clause to the query.
public havingRaw ( string $sql, array $bindings = [], string $boolean = 'and' )
$sql string
$bindings array
$boolean string

implode() public method

Concatenate values of a given column as a string.
public implode ( string $column, string $glue = '' ) : string
$column string
$glue string
return string

inRandomOrder() public method

Put the query's results in random order.
public inRandomOrder ( string $seed = '' )
$seed string

increment() public method

Increment a column's value by a given amount.
public increment ( string $column, integer $amount = 1, array $extra = [] ) : integer
$column string
$amount integer
$extra array
return integer

insert() public method

Insert a new record into the database.
public insert ( array $values ) : boolean
$values array
return boolean

insertGetId() public method

Insert a new record and get the value of the primary key.
public insertGetId ( array $values, string $sequence = null ) : integer
$values array
$sequence string
return integer

invalidOperatorAndValue() protected method

Determine if the given operator and value combination is legal.
protected invalidOperatorAndValue ( string $operator, mixed $value ) : boolean
$operator string
$value mixed
return boolean

join() public method

Add a join clause to the query.
public join ( string $table, string $one, string $operator = null, string $two = null, string $type = 'inner', boolean $where = false )
$table string
$one string
$operator string
$two string
$type string
$where boolean

joinWhere() public method

Add a "join where" clause to the query.
public joinWhere ( string $table, string $one, string $operator, string $two, string $type = 'inner' ) : Builder | static
$table string
$one string
$operator string
$two string
$type string
return Builder | static

latest() public method

Add an "order by" clause for a timestamp to the query.
public latest ( string $column = 'created_at' ) : Builder | static
$column string
return Builder | static

leftJoin() public method

Add a left join to the query.
public leftJoin ( string $table, string $first, string $operator = null, string $second = null ) : Builder | static
$table string
$first string
$operator string
$second string
return Builder | static

leftJoinWhere() public method

Add a "join where" clause to the query.
public leftJoinWhere ( string $table, string $one, string $operator, string $two ) : Builder | static
$table string
$one string
$operator string
$two string
return Builder | static

limit() public method

Set the "limit" value of the query.
public limit ( integer $value )
$value integer

lock() public method

Lock the selected rows in the table.
public lock ( boolean $value = true )
$value boolean

lockForUpdate() public method

Lock the selected rows in the table for updating.
public lockForUpdate ( ) : Builder
return Builder

macroCall() public method

public macroCall ( )

max() public method

Retrieve the maximum value of a given column.
public max ( string $column ) : mixed
$column string
return mixed

mergeBindings() public method

Merge an array of bindings into our bindings.
public mergeBindings ( Builder $query )
$query Builder

mergeWheres() public method

Merge an array of where clauses and bindings.
public mergeWheres ( array $wheres, array $bindings ) : void
$wheres array
$bindings array
return void

min() public method

Retrieve the minimum value of a given column.
public min ( string $column ) : mixed
$column string
return mixed

newQuery() public method

Get a new instance of the query builder.
public newQuery ( ) : Builder
return Builder

numericAggregate() public method

Execute a numeric aggregate function on the database.
public numericAggregate ( string $function, array $columns = ['*'] ) : float | integer
$function string
$columns array
return float | integer

offset() public method

Set the "offset" value of the query.
public offset ( integer $value )
$value integer

oldest() public method

Add an "order by" clause for a timestamp to the query.
public oldest ( string $column = 'created_at' ) : Builder | static
$column string
return Builder | static

orHaving() public method

Add a "or having" clause to the query.
public orHaving ( string $column, string $operator = null, string $value = null ) : Builder | static
$column string
$operator string
$value string
return Builder | static

orHavingRaw() public method

Add a raw or having clause to the query.
public orHavingRaw ( string $sql, array $bindings = [] ) : Builder | static
$sql string
$bindings array
return Builder | static

orWhere() public method

Add an "or where" clause to the query.
public orWhere ( Closure | string $column, string $operator = null, mixed $value = null ) : Builder | static
$column Closure | string
$operator string
$value mixed
return Builder | static

orWhereBetween() public method

Add an or where between statement to the query.
public orWhereBetween ( string $column, array $values ) : Builder | static
$column string
$values array
return Builder | static

orWhereColumn() public method

Add an "or where" clause comparing two columns to the query.
public orWhereColumn ( string | array $first, string | null $operator = null, string | null $second = null ) : Builder | static
$first string | array
$operator string | null
$second string | null
return Builder | static

orWhereDate() public method

Add an "or where date" statement to the query.
public orWhereDate ( string $column, string $operator, string $value ) : Builder | static
$column string
$operator string
$value string
return Builder | static

orWhereExists() public method

Add an or exists clause to the query.
public orWhereExists ( Closure $callback, boolean $not = false ) : Builder | static
$callback Closure
$not boolean
return Builder | static

orWhereIn() public method

Add an "or where in" clause to the query.
public orWhereIn ( string $column, mixed $values ) : Builder | static
$column string
$values mixed
return Builder | static

orWhereNotBetween() public method

Add an or where not between statement to the query.
public orWhereNotBetween ( string $column, array $values ) : Builder | static
$column string
$values array
return Builder | static

orWhereNotExists() public method

Add a where not exists clause to the query.
public orWhereNotExists ( Closure $callback ) : Builder | static
$callback Closure
return Builder | static

orWhereNotIn() public method

Add an "or where not in" clause to the query.
public orWhereNotIn ( string $column, mixed $values ) : Builder | static
$column string
$values mixed
return Builder | static

orWhereNotNull() public method

Add an "or where not null" clause to the query.
public orWhereNotNull ( string $column ) : Builder | static
$column string
return Builder | static

orWhereNull() public method

Add an "or where null" clause to the query.
public orWhereNull ( string $column ) : Builder | static
$column string
return Builder | static

orWhereRaw() public method

Add a raw or where clause to the query.
public orWhereRaw ( string $sql, array $bindings = [] ) : Builder | static
$sql string
$bindings array
return Builder | static

orWhereTime() public method

Add an "or where time" statement to the query.
public orWhereTime ( string $column, string $operator, integer $value ) : Builder | static
$column string
$operator string
$value integer
return Builder | static

orderBy() public method

Add an "order by" clause to the query.
public orderBy ( string $column, string $direction = 'asc' )
$column string
$direction string

orderByRaw() public method

Add a raw "order by" clause to the query.
public orderByRaw ( string $sql, array $bindings = [] )
$sql string
$bindings array

paginate() public method

Paginate the given query into a simple paginator.
public paginate ( integer $perPage = 15, array $columns = ['*'], string $pageName = 'page', integer | null $page = null ) : Illuminate\Contracts\Pagination\LengthAwarePaginator
$perPage integer
$columns array
$pageName string
$page integer | null
return Illuminate\Contracts\Pagination\LengthAwarePaginator

pluck() public method

Get an array with the values of a given column.
public pluck ( string $column, string | null $key = null ) : Collection
$column string
$key string | null
return Illuminate\Support\Collection

prepareValueAndOperator() protected method

Prepare the value and operator for a where clause.
protected prepareValueAndOperator ( string $value, string $operator, boolean $useDefault = false ) : array
$value string
$operator string
$useDefault boolean
return array

raw() public method

Create a raw database expression.
public raw ( mixed $value ) : Illuminate\Database\Query\Expression
$value mixed
return Illuminate\Database\Query\Expression

restoreFieldsForCount() protected method

Restore some fields after the pagination count.
protected restoreFieldsForCount ( ) : void
return void

rightJoin() public method

Add a right join to the query.
public rightJoin ( string $table, string $first, string $operator = null, string $second = null ) : Builder | static
$table string
$first string
$operator string
$second string
return Builder | static

rightJoinWhere() public method

Add a "right join where" clause to the query.
public rightJoinWhere ( string $table, string $one, string $operator, string $two ) : Builder | static
$table string
$one string
$operator string
$two string
return Builder | static

runSelect() protected method

Run the query as a "select" statement against the connection.
protected runSelect ( ) : array
return array

select() public method

Set the columns to be selected.
public select ( array | mixed $columns = ['*'] )
$columns array | mixed

selectRaw() public method

Add a new "raw" select expression to the query.
public selectRaw ( string $expression, array $bindings = [] ) : Builder | static
$expression string
$bindings array
return Builder | static

selectSub() public method

Add a subselect expression to the query.
public selectSub ( Closure | Builder | string $query, string $as ) : Builder | static
$query Closure | Builder | string
$as string
return Builder | static

setBindings() public method

Set the bindings on the query builder.
public setBindings ( array $bindings, string $type = 'where' )
$bindings array
$type string

sharedLock() public method

Share lock the selected rows in the table.
public sharedLock ( ) : Builder
return Builder

simplePaginate() public method

This is more efficient on larger data-sets, etc.
public simplePaginate ( integer $perPage = 15, array $columns = ['*'], string $pageName = 'page', integer | null $page = null ) : Illuminate\Contracts\Pagination\Paginator
$perPage integer
$columns array
$pageName string
$page integer | null
return Illuminate\Contracts\Pagination\Paginator

skip() public method

Alias to set the "offset" value of the query.
public skip ( integer $value ) : Builder | static
$value integer
return Builder | static

stripTableForPluck() protected method

Strip off the table name or alias from a column identifier.
protected stripTableForPluck ( string $column ) : string | null
$column string
return string | null

sum() public method

Retrieve the sum of the values of a given column.
public sum ( string $column ) : mixed
$column string
return mixed

take() public method

Alias to set the "limit" value of the query.
public take ( integer $value ) : Builder | static
$value integer
return Builder | static

toSql() public method

Get the SQL representation of the query.
public toSql ( ) : string
return string

truncate() public method

Run a truncate statement on the table.
public truncate ( ) : void
return void

union() public method

Add a union statement to the query.
public union ( Builder | Closure $query, boolean $all = false ) : Builder | static
$query Builder | Closure
$all boolean
return Builder | static

unionAll() public method

Add a union all statement to the query.
public unionAll ( Builder | Closure $query ) : Builder | static
$query Builder | Closure
return Builder | static

update() public method

Update a record in the database.
public update ( array $values ) : integer
$values array
return integer

updateOrInsert() public method

Insert or update a record matching the attributes, and fill it with values.
public updateOrInsert ( array $attributes, array $values = [] ) : boolean
$attributes array
$values array
return boolean

useWritePdo() public method

Use the write pdo for query.
public useWritePdo ( )

value() public method

Get a single column's value from the first result of a query.
public value ( string $column ) : mixed
$column string
return mixed

when() public method

Apply the callback's query changes if the given "value" is true.
public when ( boolean $value, Closure $callback, Closure $default = null ) : Builder
$value boolean
$callback Closure
$default Closure
return Builder

where() public method

Add a basic where clause to the query.
public where ( string | array | Closure $column, string $operator = null, mixed $value = null, string $boolean = 'and' )
$column string | array | Closure
$operator string
$value mixed
$boolean string

whereBetween() public method

Add a where between statement to the query.
public whereBetween ( string $column, array $values, string $boolean = 'and', boolean $not = false )
$column string
$values array
$boolean string
$not boolean

whereColumn() public method

Add a "where" clause comparing two columns to the query.
public whereColumn ( string | array $first, string | null $operator = null, string | null $second = null, string | null $boolean = 'and' ) : Builder | static
$first string | array
$operator string | null
$second string | null
$boolean string | null
return Builder | static

whereDate() public method

Add a "where date" statement to the query.
public whereDate ( string $column, string $operator, mixed $value = null, string $boolean = 'and' ) : Builder | static
$column string
$operator string
$value mixed
$boolean string
return Builder | static

whereDay() public method

Add a "where day" statement to the query.
public whereDay ( string $column, string $operator, mixed $value = null, string $boolean = 'and' ) : Builder | static
$column string
$operator string
$value mixed
$boolean string
return Builder | static

whereExists() public method

Add an exists clause to the query.
public whereExists ( Closure $callback, string $boolean = 'and', boolean $not = false )
$callback Closure
$boolean string
$not boolean

whereIn() public method

Add a "where in" clause to the query.
public whereIn ( string $column, mixed $values, string $boolean = 'and', boolean $not = false )
$column string
$values mixed
$boolean string
$not boolean

whereInExistingQuery() protected method

Add an external sub-select to the query.
protected whereInExistingQuery ( string $column, Builder | static $query, string $boolean, boolean $not )
$column string
$query Builder | static
$boolean string
$not boolean

whereInSub() protected method

Add a where in with a sub-select to the query.
protected whereInSub ( string $column, Closure $callback, string $boolean, boolean $not )
$column string
$callback Closure
$boolean string
$not boolean

whereMonth() public method

Add a "where month" statement to the query.
public whereMonth ( string $column, string $operator, mixed $value = null, string $boolean = 'and' ) : Builder | static
$column string
$operator string
$value mixed
$boolean string
return Builder | static

whereNested() public method

Add a nested where statement to the query.
public whereNested ( Closure $callback, string $boolean = 'and' ) : Builder | static
$callback Closure
$boolean string
return Builder | static

whereNotBetween() public method

Add a where not between statement to the query.
public whereNotBetween ( string $column, array $values, string $boolean = 'and' ) : Builder | static
$column string
$values array
$boolean string
return Builder | static

whereNotExists() public method

Add a where not exists clause to the query.
public whereNotExists ( Closure $callback, string $boolean = 'and' ) : Builder | static
$callback Closure
$boolean string
return Builder | static

whereNotIn() public method

Add a "where not in" clause to the query.
public whereNotIn ( string $column, mixed $values, string $boolean = 'and' ) : Builder | static
$column string
$values mixed
$boolean string
return Builder | static

whereNotNull() public method

Add a "where not null" clause to the query.
public whereNotNull ( string $column, string $boolean = 'and' ) : Builder | static
$column string
$boolean string
return Builder | static

whereNull() public method

Add a "where null" clause to the query.
public whereNull ( string $column, string $boolean = 'and', boolean $not = false )
$column string
$boolean string
$not boolean

whereRaw() public method

Add a raw where clause to the query.
public whereRaw ( string $sql, mixed $bindings = [], string $boolean = 'and' )
$sql string
$bindings mixed
$boolean string

whereSub() protected method

Add a full sub-select to the query.
protected whereSub ( string $column, string $operator, Closure $callback, string $boolean )
$column string
$operator string
$callback Closure
$boolean string

whereTime() public method

Add a "where time" statement to the query.
public whereTime ( string $column, string $operator, integer $value, string $boolean = 'and' ) : Builder | static
$column string
$operator string
$value integer
$boolean string
return Builder | static

whereYear() public method

Add a "where year" statement to the query.
public whereYear ( string $column, string $operator, mixed $value = null, string $boolean = 'and' ) : Builder | static
$column string
$operator string
$value mixed
$boolean string
return Builder | static

Property Details

$aggregate public_oe property

An aggregate function and column to be run.
public array $aggregate
return array

$backups protected_oe property

The field backups currently in use.
protected array $backups
return array

$bindingBackups protected_oe property

The binding backups currently in use.
protected array $bindingBackups
return array

$bindings protected_oe property

The current query value bindings.
protected array $bindings
return array

$columns public_oe property

The columns that should be returned.
public array $columns
return array

$connection protected_oe property

The database connection instance.
protected Connection,Illuminate\Database $connection
return Illuminate\Database\Connection

$distinct public_oe property

Indicates if the query returns distinct results.
public bool $distinct
return boolean

$from public_oe property

The table which the query is targeting.
public string $from
return string

$grammar protected_oe property

The database query grammar instance.
protected Grammar,Illuminate\Database\Query\Grammars $grammar
return Illuminate\Database\Query\Grammars\Grammar

$groups public_oe property

The groupings for the query.
public array $groups
return array

$havings public_oe property

The having constraints for the query.
public array $havings
return array

$joins public_oe property

The table joins for the query.
public array $joins
return array

$limit public_oe property

The maximum number of records to return.
public int $limit
return integer

$lock public_oe property

Indicates whether row locking is being used.
public string|bool $lock
return string | boolean

$offset public_oe property

The number of records to skip.
public int $offset
return integer

$operators protected_oe property

All of the available clause operators.
protected array $operators
return array

$orders public_oe property

The orderings for the query.
public array $orders
return array

$processor protected_oe property

The database query post processor instance.
protected Processor,Illuminate\Database\Query\Processors $processor
return Illuminate\Database\Query\Processors\Processor

$unionLimit public_oe property

The maximum number of union records to return.
public int $unionLimit
return integer

$unionOffset public_oe property

The number of union records to skip.
public int $unionOffset
return integer

$unionOrders public_oe property

The orderings for the union query.
public array $unionOrders
return array

$unions public_oe property

The query union statements.
public array $unions
return array

$useWritePdo protected_oe property

Whether use write pdo for select.
protected bool $useWritePdo
return boolean

$wheres public_oe property

The where constraints for the query.
public array $wheres
return array