class JoinClause extends Builder (View source)
Macroable |
array | $aggregate | An aggregate function and column to be run. | from Builder |
array | $columns | The columns that should be returned. | from Builder |
bool | $distinct | Indicates if the query returns distinct results. | from Builder |
string | $from | The table which the query is targeting. | from Builder |
array | $joins | The table joins for the query. | from Builder |
array | $wheres | The where constraints for the query. | from Builder |
array | $groups | The groupings for the query. | from Builder |
array | $havings | The having constraints for the query. | from Builder |
array | $orders | The orderings for the query. | from Builder |
int | $limit | The maximum number of records to return. | from Builder |
int | $offset | The number of records to skip. | from Builder |
array | $unions | The query union statements. | from Builder |
int | $unionLimit | The maximum number of union records to return. | from Builder |
int | $unionOffset | The number of union records to skip. | from Builder |
array | $unionOrders | The orderings for the union query. | from Builder |
string|bool | $lock | Indicates whether row locking is being used. | from Builder |
string | $type | The type of join being performed. | |
string | $table | The table the join clause is joining to. |
static void | macro(string $name, callable $macro) Register a custom macro. | from Macroable |
static bool | hasMacro(string $name) Checks if macro is registered. | from Macroable |
static mixed | __callStatic(string $method, array $parameters) Dynamically handle calls to the class. | from Macroable |
mixed | __call(string $method, array $parameters) Dynamically handle calls to the class. | from Macroable |
void | __construct(Builder $parentQuery, string $type, string $table) Create a new join clause instance. | |
$this | select(array|mixed $columns = array('*')) Set the columns to be selected. | from Builder |
Builder|Builder | selectRaw(string $expression, array $bindings = array()) Add a new "raw" select expression to the query. | from Builder |
Builder|Builder | selectSub(Closure|Builder|string $query, string $as) Add a subselect expression to the query. | from Builder |
$this | addSelect(array|mixed $column) Add a new select column to the query. | from Builder |
$this | distinct() Force the query to only return distinct results. | from Builder |
$this | from(string $table) Set the table which the query is targeting. | from Builder |
$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. | from Builder |
Builder|Builder | joinWhere(string $table, string $one, string $operator, string $two, string $type = 'inner') Add a "join where" clause to the query. | from Builder |
Builder|Builder | leftJoin(string $table, string $first, string $operator = null, string $second = null) Add a left join to the query. | from Builder |
Builder|Builder | leftJoinWhere(string $table, string $one, string $operator, string $two) Add a "join where" clause to the query. | from Builder |
Builder|Builder | rightJoin(string $table, string $first, string $operator = null, string $second = null) Add a right join to the query. | from Builder |
Builder|Builder | rightJoinWhere(string $table, string $one, string $operator, string $two) Add a "right join where" clause to the query. | from Builder |
Builder|Builder | crossJoin(string $table, string $first = null, string $operator = null, string $second = null) Add a "cross join" clause to the query. | from Builder |
Builder | when(bool $value, Closure $callback, Closure $default = null) Apply the callback's query changes if the given "value" is true. | from Builder |
$this | where(string|array|Closure $column, string $operator = null, mixed $value = null, string $boolean = 'and') Add a basic where clause to the query. | from Builder |
Builder|Builder | orWhere(Closure|string $column, string $operator = null, mixed $value = null) Add an "or where" clause to the query. | from Builder |
Builder|Builder | whereColumn(string|array $first, string|null $operator = null, string|null $second = null, string|null $boolean = 'and') Add a "where" clause comparing two columns to the query. | from Builder |
Builder|Builder | orWhereColumn(string|array $first, string|null $operator = null, string|null $second = null) Add an "or where" clause comparing two columns to the query. | from Builder |
$this | whereRaw(string $sql, mixed $bindings = array(), string $boolean = 'and') Add a raw where clause to the query. | from Builder |
Builder|Builder | orWhereRaw(string $sql, array $bindings = array()) Add a raw or where clause to the query. | from Builder |
$this | whereBetween(string $column, array $values, string $boolean = 'and', bool $not = false) Add a where between statement to the query. | from Builder |
Builder|Builder | orWhereBetween(string $column, array $values) Add an or where between statement to the query. | from Builder |
Builder|Builder | whereNotBetween(string $column, array $values, string $boolean = 'and') Add a where not between statement to the query. | from Builder |
Builder|Builder | orWhereNotBetween(string $column, array $values) Add an or where not between statement to the query. | from Builder |
Builder|Builder | whereNested(Closure $callback, string $boolean = 'and') Add a nested where statement to the query. | from Builder |
Builder | forNestedWhere() Create a new query instance for nested where condition. | from Builder |
$this | addNestedWhereQuery(Builder|Builder $query, string $boolean = 'and') Add another query builder as a nested where to the query builder. | from Builder |
$this | whereExists(Closure $callback, string $boolean = 'and', bool $not = false) Add an exists clause to the query. | from Builder |
Builder|Builder | orWhereExists(Closure $callback, bool $not = false) Add an or exists clause to the query. | from Builder |
Builder|Builder | whereNotExists(Closure $callback, string $boolean = 'and') Add a where not exists clause to the query. | from Builder |
Builder|Builder | orWhereNotExists(Closure $callback) Add a where not exists clause to the query. | from Builder |
$this | addWhereExistsQuery(Builder $query, string $boolean = 'and', bool $not = false) Add an exists clause to the query. | from Builder |
$this | whereIn(string $column, mixed $values, string $boolean = 'and', bool $not = false) Add a "where in" clause to the query. | from Builder |
Builder|Builder | orWhereIn(string $column, mixed $values) Add an "or where in" clause to the query. | from Builder |
Builder|Builder | whereNotIn(string $column, mixed $values, string $boolean = 'and') Add a "where not in" clause to the query. | from Builder |
Builder|Builder | orWhereNotIn(string $column, mixed $values) Add an "or where not in" clause to the query. | from Builder |
$this | whereNull(string $column, string $boolean = 'and', bool $not = false) Add a "where null" clause to the query. | from Builder |
Builder|Builder | orWhereNull(string $column) Add an "or where null" clause to the query. | from Builder |
Builder|Builder | whereNotNull(string $column, string $boolean = 'and') Add a "where not null" clause to the query. | from Builder |
Builder|Builder | orWhereNotNull(string $column) Add an "or where not null" clause to the query. | from Builder |
Builder|Builder | whereDate(string $column, string $operator, mixed $value = null, string $boolean = 'and') Add a "where date" statement to the query. | from Builder |
Builder|Builder | orWhereDate(string $column, string $operator, string $value) Add an "or where date" statement to the query. | from Builder |
Builder|Builder | whereTime(string $column, string $operator, int $value, string $boolean = 'and') Add a "where time" statement to the query. | from Builder |
Builder|Builder | orWhereTime(string $column, string $operator, int $value) Add an "or where time" statement to the query. | from Builder |
Builder|Builder | whereDay(string $column, string $operator, mixed $value = null, string $boolean = 'and') Add a "where day" statement to the query. | from Builder |
Builder|Builder | whereMonth(string $column, string $operator, mixed $value = null, string $boolean = 'and') Add a "where month" statement to the query. | from Builder |
Builder|Builder | whereYear(string $column, string $operator, mixed $value = null, string $boolean = 'and') Add a "where year" statement to the query. | from Builder |
$this | dynamicWhere(string $method, string $parameters) Handles dynamic "where" clauses to the query. | from Builder |
$this | groupBy(array $groups) Add a "group by" clause to the query. | from Builder |
$this | having(string $column, string $operator = null, string $value = null, string $boolean = 'and') Add a "having" clause to the query. | from Builder |
Builder|Builder | orHaving(string $column, string $operator = null, string $value = null) Add a "or having" clause to the query. | from Builder |
$this | havingRaw(string $sql, array $bindings = array(), string $boolean = 'and') Add a raw having clause to the query. | from Builder |
Builder|Builder | orHavingRaw(string $sql, array $bindings = array()) Add a raw or having clause to the query. | from Builder |
$this | orderBy(string $column, string $direction = 'asc') Add an "order by" clause to the query. | from Builder |
Builder|Builder | latest(string $column = 'created_at') Add an "order by" clause for a timestamp to the query. | from Builder |
Builder|Builder | oldest(string $column = 'created_at') Add an "order by" clause for a timestamp to the query. | from Builder |
$this | inRandomOrder(string $seed = '') Put the query's results in random order. | from Builder |
$this | orderByRaw(string $sql, array $bindings = array()) Add a raw "order by" clause to the query. | from Builder |
$this | offset(int $value) Set the "offset" value of the query. | from Builder |
Builder|Builder | skip(int $value) Alias to set the "offset" value of the query. | from Builder |
$this | limit(int $value) Set the "limit" value of the query. | from Builder |
Builder|Builder | take(int $value) Alias to set the "limit" value of the query. | from Builder |
Builder|Builder | forPage(int $page, int $perPage = 15) Set the limit and offset for a given page. | from Builder |
Builder|Builder | forPageAfterId(int $perPage = 15, int $lastId, string $column = 'id') Constrain the query to the next "page" of results after a given ID. | from Builder |
Builder|Builder | union(Builder|Closure $query, bool $all = false) Add a union statement to the query. | from Builder |
Builder|Builder | unionAll(Builder|Closure $query) Add a union all statement to the query. | from Builder |
$this | lock(bool $value = true) Lock the selected rows in the table. | from Builder |
Builder | lockForUpdate() Lock the selected rows in the table for updating. | from Builder |
Builder | sharedLock() Share lock the selected rows in the table. | from Builder |
string | toSql() Get the SQL representation of the query. | from Builder |
mixed|Builder | find(int $id, array $columns = array('*')) Execute a query for a single record by ID. | from Builder |
mixed | value(string $column) Get a single column's value from the first result of a query. | from Builder |
stdClass|array|null | first(array $columns = array('*')) Execute the query and get the first result. | from Builder |
Collection | get(array $columns = array('*')) Execute the query as a "select" statement. | from Builder |
LengthAwarePaginator | paginate(int $perPage = 15, array $columns = array('*'), string $pageName = 'page', int|null $page = null) Paginate the given query into a simple paginator. | from Builder |
Paginator | simplePaginate(int $perPage = 15, array $columns = array('*'), string $pageName = 'page', int|null $page = null) Get a paginator only supporting simple next and previous links. | from Builder |
int | getCountForPagination(array $columns = array('*')) Get the count of the total records for the paginator. | from Builder |
Generator | cursor() Get a generator for the given query. | from Builder |
bool | chunk(int $count, callable $callback) Chunk the results of the query. | from Builder |
bool | chunkById(int $count, callable $callback, string $column = 'id', string $alias = null) Chunk the results of a query by comparing numeric IDs. | from Builder |
bool | each(callable $callback, int $count = 1000) Execute a callback over each item while chunking. | from Builder |
Collection | pluck(string $column, string|null $key = null) Get an array with the values of a given column. | from Builder |
string | implode(string $column, string $glue = '') Concatenate values of a given column as a string. | from Builder |
bool | exists() Determine if any rows exist for the current query. | from Builder |
int | count(string $columns = '*') Retrieve the "count" result of the query. | from Builder |
mixed | min(string $column) Retrieve the minimum value of a given column. | from Builder |
mixed | max(string $column) Retrieve the maximum value of a given column. | from Builder |
mixed | sum(string $column) Retrieve the sum of the values of a given column. | from Builder |
mixed | avg(string $column) Retrieve the average of the values of a given column. | from Builder |
mixed | average(string $column) Alias for the "avg" method. | from Builder |
mixed | aggregate(string $function, array $columns = array('*')) Execute an aggregate function on the database. | from Builder |
float|int | numericAggregate(string $function, array $columns = array('*')) Execute a numeric aggregate function on the database. | from Builder |
bool | insert(array $values) Insert a new record into the database. | from Builder |
int | insertGetId(array $values, string $sequence = null) Insert a new record and get the value of the primary key. | from Builder |
int | update(array $values) Update a record in the database. | from Builder |
bool | updateOrInsert(array $attributes, array $values = array()) Insert or update a record matching the attributes, and fill it with values. | from Builder |
int | increment(string $column, int $amount = 1, array $extra = array()) Increment a column's value by a given amount. | from Builder |
int | decrement(string $column, int $amount = 1, array $extra = array()) Decrement a column's value by a given amount. | from Builder |
int | delete(mixed $id = null) Delete a record from the database. | from Builder |
void | truncate() Run a truncate statement on the table. | from Builder |
Builder | newQuery() Get a new instance of the join clause builder. | |
void | mergeWheres(array $wheres, array $bindings) Merge an array of where clauses and bindings. | from Builder |
Expression | raw(mixed $value) Create a raw database expression. | from Builder |
array | getBindings() Get the current query value bindings in a flattened array. | from Builder |
array | getRawBindings() Get the raw array of bindings. | from Builder |
$this | setBindings(array $bindings, string $type = 'where') Set the bindings on the query builder. | from Builder |
$this | addBinding(mixed $value, string $type = 'where') Add a binding to the query. | from Builder |
$this | mergeBindings(Builder $query) Merge an array of bindings into our bindings. | from Builder |
ConnectionInterface | getConnection() Get the database connection instance. | from Builder |
Processor | getProcessor() Get the database query processor instance. | from Builder |
Grammar | getGrammar() Get the query grammar instance. | from Builder |
$this | useWritePdo() Use the write pdo for query. | from Builder |
$this | on(Closure|string $first, string|null $operator = null, string|null $second = null, string $boolean = 'and') Add an "on" clause to the join. | |
JoinClause | orOn(Closure|string $first, string|null $operator = null, string|null $second = null) Add an "or on" clause to the join. |
Register a custom macro.
Checks if macro is registered.
Dynamically handle calls to the class.
Dynamically handle calls to the class.
Create a new join clause instance.
Set the columns to be selected.
Add a new "raw" select expression to the query.
Add a subselect expression to the query.
Add a new select column to the query.
Force the query to only return distinct results.
Set the table which the query is targeting.
Add a join clause to the query.
Add a "join where" clause to the query.
Add a left join to the query.
Add a "join where" clause to the query.
Add a right join to the query.
Add a "right join where" clause to the query.
Add a "cross join" clause to the query.
Apply the callback's query changes if the given "value" is true.
Add a basic where clause to the query.
Add an "or where" clause to the query.
Add a "where" clause comparing two columns to the query.
Add an "or where" clause comparing two columns to the query.
Add a raw where clause to the query.
Add a raw or where clause to the query.
Add a where between statement to the query.
Add an or where between statement to the query.
Add a where not between statement to the query.
Add an or where not between statement to the query.
Add a nested where statement to the query.
Create a new query instance for nested where condition.
Add another query builder as a nested where to the query builder.
Add an exists clause to the query.
Add an or exists clause to the query.
Add a where not exists clause to the query.
Add an exists clause to the query.
Add a "where in" clause to the query.
Add a "where not in" clause to the query.
Add an "or where not in" clause to the query.
Add a "where null" clause to the query.
Add a "where not null" clause to the query.
Add a "where date" statement to the query.
Add an "or where date" statement to the query.
Add a "where time" statement to the query.
Add an "or where time" statement to the query.
Add a "where day" statement to the query.
Add a "where month" statement to the query.
Add a "where year" statement to the query.
Handles dynamic "where" clauses to the query.
Add a "group by" clause to the query.
Add a "having" clause to the query.
Add a "or having" clause to the query.
Add a raw having clause to the query.
Add a raw or having clause to the query.
Add an "order by" clause to the query.
Add an "order by" clause for a timestamp to the query.
Add an "order by" clause for a timestamp to the query.
Put the query's results in random order.
Add a raw "order by" clause to the query.
Set the "offset" value of the query.
Set the "limit" value of the query.
Constrain the query to the next "page" of results after a given ID.
Add a union statement to the query.
Lock the selected rows in the table.
Lock the selected rows in the table for updating.
Share lock the selected rows in the table.
Get the SQL representation of the query.
Execute a query for a single record by ID.
Get a single column's value from the first result of a query.
Execute the query and get the first result.
Execute the query as a "select" statement.
Paginate the given query into a simple paginator.
Get a paginator only supporting simple next and previous links.
This is more efficient on larger data-sets, etc.
Get the count of the total records for the paginator.
Get a generator for the given query.
Chunk the results of the query.
Chunk the results of a query by comparing numeric IDs.
Execute a callback over each item while chunking.
Get an array with the values of a given column.
Concatenate values of a given column as a string.
Determine if any rows exist for the current query.
Retrieve the "count" result of the query.
Retrieve the minimum value of a given column.
Retrieve the maximum value of a given column.
Retrieve the sum of the values of a given column.
Retrieve the average of the values of a given column.
Alias for the "avg" method.
Execute an aggregate function on the database.
Execute a numeric aggregate function on the database.
Insert a new record into the database.
Insert a new record and get the value of the primary key.
Update a record in the database.
Insert or update a record matching the attributes, and fill it with values.
Increment a column's value by a given amount.
Decrement a column's value by a given amount.
Delete a record from the database.
Run a truncate statement on the table.
Get a new instance of the join clause builder.
Merge an array of where clauses and bindings.
Create a raw database expression.
Get the current query value bindings in a flattened array.
Get the raw array of bindings.
Set the bindings on the query builder.
Add a binding to the query.
Merge an array of bindings into our bindings.
Get the database connection instance.
Get the database query processor instance.
Get the query grammar instance.
Use the write pdo for query.
Add an "on" clause to the join.
On clauses can be chained, e.g.
$join->on('contacts.userid', '=', 'users.id') ->on('contacts.infoid', '=', 'info.id')
will produce the following SQL:
on contacts
.user_id
= users
.id
and contacts
.info_id
= info
.id
Add an "or on" clause to the join.
© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/5.3/Illuminate/Database/Query/JoinClause.html