class Builder (View source)

Properties

protected Connection $connection The database connection instance.
protected Grammar $grammar The database query grammar instance.
protected Processor $processor The database query post processor instance.
protected array $bindings The current query value bindings.
array $aggregate An aggregate function and column to be run.
array $columns The columns that should be returned.
bool $distinct Indicates if the query returns distinct results.
string $from The table which the query is targeting.
array $joins The table joins for the query.
array $wheres The where constraints for the query.
array $groups The groupings for the query.
array $havings The having constraints for the query.
array $orders The orderings for the query.
int $limit The maximum number of records to return.
int $offset The number of records to skip.
array $unions The query union statements.
int $unionLimit The maximum number of union records to return.
int $unionOffset The number of union records to skip.
array $unionOrders The orderings for the union query.
string|bool $lock Indicates whether row locking is being used.
protected array $backups The backups of fields while doing a pagination count.
protected string $cacheKey The key that should be used when caching the query.
protected int $cacheMinutes The number of minutes to cache the query.
protected array $cacheTags The tags for the query cache.
protected string $cacheDriver The cache driver to be used.
protected array $operators All of the available clause operators.
protected bool $useWritePdo Whether use write pdo for select.

Methods

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

Create a new query builder instance.

$this
select(array $columns = array('*'))

Set the columns to be selected.

selectRaw(string $expression)

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

$this
addSelect(mixed $column)

Add a new select column to the query.

$this
distinct()

Force the query to only return distinct results.

$this
from(string $table)

Set the table which the query is targeting.

$this
join(string $table, string $one, string $operator = null, string $two = null, string $type = 'inner', bool $where = false)

Add a join clause to the query.

joinWhere(string $table, string $one, string $operator, string $two, string $type = 'inner')

Add a "join where" clause to the query.

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

Add a left join to the query.

leftJoinWhere(string $table, string $one, string $operator, string $two)

Add a "join where" clause to the query.

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

Add a right join to the query.

rightJoinWhere(string $table, string $one, string $operator, string $two)

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

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

Add a basic where clause to the query.

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

Add an "or where" clause to the query.

bool
invalidOperatorAndValue(string $operator, mixed $value)

Determine if the given operator and value combination is legal.

$this
whereRaw(string $sql, array $bindings = array(), string $boolean = 'and')

Add a raw where clause to the query.

orWhereRaw(string $sql, array $bindings = array())

Add a raw or where clause to the query.

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

Add a where between statement to the query.

orWhereBetween(string $column, array $values)

Add an or where between statement to the query.

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

Add a where not between statement to the query.

orWhereNotBetween(string $column, array $values)

Add an or where not between statement to the query.

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

Add a nested where statement to the query.

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

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

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

Add a full sub-select to the query.

$this
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.

$this
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.

$this
whereInSub(string $column, Closure $callback, string $boolean, bool $not)

Add a where in with a sub-select to the query.

$this
whereNull(string $column, string $boolean = 'and', bool $not = false)

Add a "where null" clause to the query.

orWhereNull(string $column)

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

whereNotNull(string $column, string $boolean = 'and')

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

orWhereNotNull(string $column)

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

whereDate(string $column, string $operator, int $value, string $boolean = 'and')

Add a "where date" statement to the query.

whereDay(string $column, string $operator, int $value, string $boolean = 'and')

Add a "where day" statement to the query.

whereMonth(string $column, string $operator, int $value, string $boolean = 'and')

Add a "where month" statement to the query.

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

Add a "where year" statement to the query.

$this
addDateBasedWhere(string $type, string $column, string $operator, int $value, string $boolean = 'and')

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

$this
dynamicWhere(string $method, string $parameters)

Handles dynamic "where" clauses to the query.

void
addDynamic(string $segment, string $connector, array $parameters, int $index)

Add a single dynamic where clause statement to the query.

$this
groupBy()

Add a "group by" clause to the query.

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

Add a "having" clause to the query.

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

Add a "or having" clause to the query.

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

Add a raw having clause to the query.

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

Add a raw or having clause to the query.

$this
orderBy(string $column, string $direction = 'asc')

Add an "order by" clause to the query.

latest(string $column = 'created_at')

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

oldest(string $column = 'created_at')

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

$this
orderByRaw(string $sql, array $bindings = array())

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

$this
offset(int $value)

Set the "offset" value of the query.

skip(int $value)

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

$this
limit(int $value)

Set the "limit" value of the query.

take(int $value)

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

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

Set the limit and offset for a given page.

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.

$this
lock(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.

string
toSql()

Get the SQL representation of the query.

$this
remember(DateTime|int $minutes, string $key = null)

Indicate that the query results should be cached.

rememberForever(string $key = null)

Indicate that the query results should be cached forever.

$this
cacheTags(array|mixed $cacheTags)

Indicate that the results, if cached, should use the given cache tags.

$this
cacheDriver(string $cacheDriver)

Indicate that the results, if cached, should use the given cache driver.

mixed|Builder
find(int $id, array $columns = array('*'))

Execute a query for a single record by ID.

mixed
pluck(string $column)

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

mixed|Builder
first(array $columns = array('*'))

Execute the query and get the first result.

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

Execute the query as a "select" statement.

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

Execute the query as a fresh "select" statement.

array
runSelect()

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

array
getCached(array $columns = array('*'))

Execute the query as a cached "select" statement.

getCache()

Get the cache object with tags assigned, if applicable.

array
getCacheInfo()

Get the cache key and cache minutes as an array.

string
getCacheKey()

Get a unique cache key for the complete query.

string
generateCacheKey()

Generate the unique cache key for the query.

getCacheCallback(array $columns)

Get the Closure callback used when caching queries.

void
chunk(int $count, callable $callback)

Chunk the results of the query.

array
lists(string $column, string $key = null)

Get an array with the values of a given column.

array
getListSelect(string $column, string $key)

Get the columns that should be used in a list array.

string
implode(string $column, string $glue = null)

Concatenate values of a given column as a string.

paginate(int $perPage = 15, array $columns = array('*'))

Get a paginator for the "select" statement.

groupedPaginate(Factory $paginator, int $perPage, array $columns)

Create a paginator for a grouped pagination statement.

buildRawPaginator(Factory $paginator, array $results, int $perPage)

Build a paginator instance from a raw result array.

ungroupedPaginate(Factory $paginator, int $perPage, array $columns)

Create a paginator for an un-grouped pagination statement.

int
getPaginationCount()

Get the count of the total records for pagination.

simplePaginate(int $perPage = null, array $columns = array('*'))

Get a paginator only supporting simple next and previous links.

void
backupFieldsForCount()

Backup certain fields for a pagination count.

void
restoreFieldsForCount()

Restore certain fields for a pagination count.

bool
exists()

Determine if any rows exist for the current query.

int
count(string $columns = '*')

Retrieve the "count" result of the query.

mixed
min(string $column)

Retrieve the minimum value of a given column.

mixed
max(string $column)

Retrieve the maximum value of a given column.

mixed
sum(string $column)

Retrieve the sum of the values of a given column.

mixed
avg(string $column)

Retrieve the average of the values of a given column.

mixed
aggregate(string $function, array $columns = array('*'))

Execute an aggregate function on the database.

bool
insert(array $values)

Insert a new record into the database.

int
insertGetId(array $values, string $sequence = null)

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

int
update(array $values)

Update a record in the database.

int
increment(string $column, int $amount = 1, array $extra = array())

Increment a column's value by a given amount.

int
decrement(string $column, int $amount = 1, array $extra = array())

Decrement a column's value by a given amount.

int
delete(mixed $id = null)

Delete a record from the database.

void
truncate()

Run a truncate statement on the table.

newQuery()

Get a new instance of the query builder.

void
mergeWheres(array $wheres, array $bindings)

Merge an array of where clauses and bindings.

array
cleanBindings(array $bindings)

Remove all of the expressions from a list of bindings.

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.

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

Set the bindings on the query builder.

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

Add a binding to the query.

$this
mergeBindings(Builder $query)

Merge an array of bindings into our bindings.

getConnection()

Get the database connection instance.

getProcessor()

Get the database query processor instance.

getGrammar()

Get the query grammar instance.

$this
useWritePdo()

Use the write pdo for query.

mixed
__call(string $method, array $parameters)

Handle dynamic method calls into the method.

Details

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

Create a new query builder instance.

Parameters

ConnectionInterface $connection
Grammar $grammar
Processor $processor

Return Value

void

$this select(array $columns = array('*'))

Set the columns to be selected.

Parameters

array $columns

Return Value

$this

Builder|Builder selectRaw(string $expression)

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

Parameters

string $expression

Return Value

Builder|Builder

$this addSelect(mixed $column)

Add a new select column to the query.

Parameters

mixed $column

Return Value

$this

$this distinct()

Force the query to only return distinct results.

Return Value

$this

$this from(string $table)

Set the table which the query is targeting.

Parameters

string $table

Return Value

$this

$this join(string $table, string $one, string $operator = null, string $two = null, string $type = 'inner', bool $where = false)

Add a join clause to the query.

Parameters

string $table
string $one
string $operator
string $two
string $type
bool $where

Return Value

$this

Builder|Builder joinWhere(string $table, string $one, string $operator, string $two, string $type = 'inner')

Add a "join where" clause to the query.

Parameters

string $table
string $one
string $operator
string $two
string $type

Return Value

Builder|Builder

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

Add a left join to the query.

Parameters

string $table
string $first
string $operator
string $second

Return Value

Builder|Builder

Builder|Builder leftJoinWhere(string $table, string $one, string $operator, string $two)

Add a "join where" clause to the query.

Parameters

string $table
string $one
string $operator
string $two

Return Value

Builder|Builder

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

Add a right join to the query.

Parameters

string $table
string $first
string $operator
string $second

Return Value

Builder|Builder

Builder|Builder rightJoinWhere(string $table, string $one, string $operator, string $two)

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

Parameters

string $table
string $one
string $operator
string $two

Return Value

Builder|Builder

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

Add a basic where clause to the query.

Parameters

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

Return Value

$this

Exceptions

InvalidArgumentException

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

Add an "or where" clause to the query.

Parameters

string $column
string $operator
mixed $value

Return Value

Builder|Builder

protected bool invalidOperatorAndValue(string $operator, mixed $value)

Determine if the given operator and value combination is legal.

Parameters

string $operator
mixed $value

Return Value

bool

$this whereRaw(string $sql, array $bindings = array(), string $boolean = 'and')

Add a raw where clause to the query.

Parameters

string $sql
array $bindings
string $boolean

Return Value

$this

Builder|Builder orWhereRaw(string $sql, array $bindings = array())

Add a raw or where clause to the query.

Parameters

string $sql
array $bindings

Return Value

Builder|Builder

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

Add a where between statement to the query.

Parameters

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

Return Value

$this

Builder|Builder orWhereBetween(string $column, array $values)

Add an or where between statement to the query.

Parameters

string $column
array $values

Return Value

Builder|Builder

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

Add a where not between statement to the query.

Parameters

string $column
array $values
string $boolean

Return Value

Builder|Builder

Builder|Builder orWhereNotBetween(string $column, array $values)

Add an or where not between statement to the query.

Parameters

string $column
array $values

Return Value

Builder|Builder

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

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

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

Parameters

Builder|Builder $query
string $boolean

Return Value

$this

protected $this whereSub(string $column, string $operator, Closure $callback, string $boolean)

Add a full sub-select to the query.

Parameters

string $column
string $operator
Closure $callback
string $boolean

Return Value

$this

$this 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

$this

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

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

Builder|Builder orWhereNotExists(Closure $callback)

Add a where not exists clause to the query.

Parameters

Closure $callback

Return Value

Builder|Builder

$this 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

$this

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

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

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

protected $this whereInSub(string $column, Closure $callback, string $boolean, bool $not)

Add a where in with a sub-select to the query.

Parameters

string $column
Closure $callback
string $boolean
bool $not

Return Value

$this

$this whereNull(string $column, string $boolean = 'and', bool $not = false)

Add a "where null" clause to the query.

Parameters

string $column
string $boolean
bool $not

Return Value

$this

Builder|Builder orWhereNull(string $column)

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

Parameters

string $column

Return Value

Builder|Builder

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

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

Parameters

string $column
string $boolean

Return Value

Builder|Builder

Builder|Builder orWhereNotNull(string $column)

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

Parameters

string $column

Return Value

Builder|Builder

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

Add a "where date" statement to the query.

Parameters

string $column
string $operator
int $value
string $boolean

Return Value

Builder|Builder

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

Add a "where day" statement to the query.

Parameters

string $column
string $operator
int $value
string $boolean

Return Value

Builder|Builder

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

Add a "where month" statement to the query.

Parameters

string $column
string $operator
int $value
string $boolean

Return Value

Builder|Builder

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

Add a "where year" statement to the query.

Parameters

string $column
string $operator
int $value
string $boolean

Return Value

Builder|Builder

protected $this addDateBasedWhere(string $type, string $column, string $operator, int $value, string $boolean = 'and')

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

Parameters

string $type
string $column
string $operator
int $value
string $boolean

Return Value

$this

$this dynamicWhere(string $method, string $parameters)

Handles dynamic "where" clauses to the query.

Parameters

string $method
string $parameters

Return Value

$this

protected void addDynamic(string $segment, string $connector, array $parameters, int $index)

Add a single dynamic where clause statement to the query.

Parameters

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

Return Value

void

$this groupBy()

Add a "group by" clause to the query.

Return Value

$this

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

Add a "having" clause to the query.

Parameters

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

Return Value

$this

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

Add a "or having" clause to the query.

Parameters

string $column
string $operator
string $value

Return Value

Builder|Builder

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

Add a raw having clause to the query.

Parameters

string $sql
array $bindings
string $boolean

Return Value

$this

Builder|Builder orHavingRaw(string $sql, array $bindings = array())

Add a raw or having clause to the query.

Parameters

string $sql
array $bindings

Return Value

Builder|Builder

$this orderBy(string $column, string $direction = 'asc')

Add an "order by" clause to the query.

Parameters

string $column
string $direction

Return Value

$this

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

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

Parameters

string $column

Return Value

Builder|Builder

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

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

Parameters

string $column

Return Value

Builder|Builder

$this orderByRaw(string $sql, array $bindings = array())

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

Parameters

string $sql
array $bindings

Return Value

$this

$this offset(int $value)

Set the "offset" value of the query.

Parameters

int $value

Return Value

$this

Builder|Builder skip(int $value)

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

Parameters

int $value

Return Value

Builder|Builder

$this limit(int $value)

Set the "limit" value of the query.

Parameters

int $value

Return Value

$this

Builder|Builder take(int $value)

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

Parameters

int $value

Return Value

Builder|Builder

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

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

Builder|Builder unionAll(Builder|Closure $query)

Add a union all statement to the query.

Parameters

Builder|Closure $query

Return Value

Builder|Builder

$this lock(bool $value = true)

Lock the selected rows in the table.

Parameters

bool $value

Return Value

$this

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

string toSql()

Get the SQL representation of the query.

Return Value

string

$this remember(DateTime|int $minutes, string $key = null)

Indicate that the query results should be cached.

Parameters

DateTime|int $minutes
string $key

Return Value

$this

Builder|Builder rememberForever(string $key = null)

Indicate that the query results should be cached forever.

Parameters

string $key

Return Value

Builder|Builder

$this cacheTags(array|mixed $cacheTags)

Indicate that the results, if cached, should use the given cache tags.

Parameters

array|mixed $cacheTags

Return Value

$this

$this cacheDriver(string $cacheDriver)

Indicate that the results, if cached, should use the given cache driver.

Parameters

string $cacheDriver

Return Value

$this

mixed|Builder find(int $id, array $columns = array('*'))

Execute a query for a single record by ID.

Parameters

int $id
array $columns

Return Value

mixed|Builder

mixed pluck(string $column)

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

Parameters

string $column

Return Value

mixed

mixed|Builder first(array $columns = array('*'))

Execute the query and get the first result.

Parameters

array $columns

Return Value

mixed|Builder

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

Execute the query as a "select" statement.

Parameters

array $columns

Return Value

array|Builder[]

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

Execute the query as a fresh "select" statement.

Parameters

array $columns

Return Value

array|Builder[]

protected array runSelect()

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

Return Value

array

array getCached(array $columns = array('*'))

Execute the query as a cached "select" statement.

Parameters

array $columns

Return Value

array

protected CacheManager getCache()

Get the cache object with tags assigned, if applicable.

Return Value

CacheManager

protected array getCacheInfo()

Get the cache key and cache minutes as an array.

Return Value

array

string getCacheKey()

Get a unique cache key for the complete query.

Return Value

string

string generateCacheKey()

Generate the unique cache key for the query.

Return Value

string

protected Closure getCacheCallback(array $columns)

Get the Closure callback used when caching queries.

Parameters

array $columns

Return Value

Closure

void chunk(int $count, callable $callback)

Chunk the results of the query.

Parameters

int $count
callable $callback

Return Value

void

array lists(string $column, string $key = null)

Get an array with the values of a given column.

Parameters

string $column
string $key

Return Value

array

protected array getListSelect(string $column, string $key)

Get the columns that should be used in a list array.

Parameters

string $column
string $key

Return Value

array

string implode(string $column, string $glue = null)

Concatenate values of a given column as a string.

Parameters

string $column
string $glue

Return Value

string

Paginator paginate(int $perPage = 15, array $columns = array('*'))

Get a paginator for the "select" statement.

Parameters

int $perPage
array $columns

Return Value

Paginator

protected Paginator groupedPaginate(Factory $paginator, int $perPage, array $columns)

Create a paginator for a grouped pagination statement.

Parameters

Factory $paginator
int $perPage
array $columns

Return Value

Paginator

Paginator buildRawPaginator(Factory $paginator, array $results, int $perPage)

Build a paginator instance from a raw result array.

Parameters

Factory $paginator
array $results
int $perPage

Return Value

Paginator

protected Paginator ungroupedPaginate(Factory $paginator, int $perPage, array $columns)

Create a paginator for an un-grouped pagination statement.

Parameters

Factory $paginator
int $perPage
array $columns

Return Value

Paginator

int getPaginationCount()

Get the count of the total records for pagination.

Return Value

int

Paginator simplePaginate(int $perPage = null, array $columns = array('*'))

Get a paginator only supporting simple next and previous links.

This is more efficient on larger data-sets, etc.

Parameters

int $perPage
array $columns

Return Value

Paginator

protected void backupFieldsForCount()

Backup certain fields for a pagination count.

Return Value

void

protected void restoreFieldsForCount()

Restore certain fields for a pagination count.

Return Value

void

bool exists()

Determine if any rows exist for the current query.

Return Value

bool

int count(string $columns = '*')

Retrieve the "count" result of the query.

Parameters

string $columns

Return Value

int

mixed min(string $column)

Retrieve the minimum value of a given column.

Parameters

string $column

Return Value

mixed

mixed max(string $column)

Retrieve the maximum value of a given column.

Parameters

string $column

Return Value

mixed

mixed sum(string $column)

Retrieve the sum of the values of a given column.

Parameters

string $column

Return Value

mixed

mixed avg(string $column)

Retrieve the average of the values of a given column.

Parameters

string $column

Return Value

mixed

mixed aggregate(string $function, array $columns = array('*'))

Execute an aggregate function on the database.

Parameters

string $function
array $columns

Return Value

mixed

bool insert(array $values)

Insert a new record into the database.

Parameters

array $values

Return Value

bool

int insertGetId(array $values, string $sequence = null)

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

Parameters

array $values
string $sequence

Return Value

int

int update(array $values)

Update a record in the database.

Parameters

array $values

Return Value

int

int increment(string $column, int $amount = 1, array $extra = array())

Increment a column's value by a given amount.

Parameters

string $column
int $amount
array $extra

Return Value

int

int decrement(string $column, int $amount = 1, array $extra = array())

Decrement a column's value by a given amount.

Parameters

string $column
int $amount
array $extra

Return Value

int

int delete(mixed $id = null)

Delete a record from the database.

Parameters

mixed $id

Return Value

int

void truncate()

Run a truncate statement on the table.

Return Value

void

Builder newQuery()

Get a new instance of the query builder.

Return Value

Builder

void mergeWheres(array $wheres, array $bindings)

Merge an array of where clauses and bindings.

Parameters

array $wheres
array $bindings

Return Value

void

protected array cleanBindings(array $bindings)

Remove all of the expressions from a list of bindings.

Parameters

array $bindings

Return Value

array

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

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

Set the bindings on the query builder.

Parameters

array $bindings
string $type

Return Value

$this

Exceptions

InvalidArgumentException

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

Add a binding to the query.

Parameters

mixed $value
string $type

Return Value

$this

Exceptions

InvalidArgumentException

$this mergeBindings(Builder $query)

Merge an array of bindings into our bindings.

Parameters

Builder $query

Return Value

$this

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

$this useWritePdo()

Use the write pdo for query.

Return Value

$this

mixed __call(string $method, array $parameters)

Handle dynamic method calls into the method.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException