Illuminate\Database\Query\Builder::join PHP Method

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
    public function join($table, $one, $operator = null, $two = null, $type = 'inner', $where = false)
    {
        $join = new JoinClause($this, $type, $table);
        // If the first "column" of the join is really a Closure instance the developer
        // is trying to build a join with a complex "on" clause containing more than
        // one condition, so we'll add the join and call a Closure with the query.
        if ($one instanceof Closure) {
            call_user_func($one, $join);
            $this->joins[] = $join;
            $this->addBinding($join->getBindings(), 'join');
        } else {
            $method = $where ? 'where' : 'on';
            $this->joins[] = $join->{$method}($one, $operator, $two);
            $this->addBinding($join->getBindings(), 'join');
        }
        return $this;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * @param string $table table name
  * @param string $key $table.key
  * @param string|bool $fkey $this->table.key
  * @return $this
  */
 public function innerJoinOn($table, $key, $fkey = false)
 {
     $fkey = $fkey ?: $key;
     $key = starts_with($key, $table . '.') ? $key : $table . '.' . $key;
     $fkey = starts_with($key, $this->table . '.') ? $fkey : $this->table . '.' . $fkey;
     $this->operator = $this->operator->join($table, $key, '=', $fkey);
     return $this;
 }
All Usage Examples Of Illuminate\Database\Query\Builder::join