public function join($table, $localKey, $operator = null, $referenceKey = null, $type = 'left')
    {
        // validate the join type
        if (!in_array($type, array('inner', 'left', 'right', 'outer')))
        {
            throw new Exception('Invalid join type "'.$type.'" given. Available type: inner, left, right, outer');
        }

        // to make nested joins possible you can pass an closure
        // wich will create a new query where you can add your nested wheres
        if (is_object($localKey) && ($localKey instanceof \Closure)) 
        {
            // create new query object
            $subquery = new SelectJoin;

            // run the closure callback on the sub query
            call_user_func_array($localKey, array(&$subquery));
    
            // add the join
            $this->joins[] = array($type, $table, $subquery); return $this;
        }

        $this->joins[] = array($type, $table, $localKey, $operator, $referenceKey); return $this;
    }
public function join($table, $localKey, $operator = null, $referenceKey = null, $type = 'left')
    {
        // validate the join type
        if (!in_array($type, array('inner', 'left', 'right', 'outer')))
        {
            throw new Exception('Invalid join type "'.$type.'" given. Available type: inner, left, right, outer');
        }

        // to make nested joins possible you can pass an closure
        // wich will create a new query where you can add your nested wheres
        if (is_object($localKey) && ($localKey instanceof \Closure)) 
        {
            // create new query object
            $subquery = new SelectJoin;

            // run the closure callback on the sub query
            call_user_func_array($localKey, array(&$subquery));
    
            // add the join
            $this->joins[] = array($type, $table, $subquery); return $this;
        }

        $this->joins[] = array($type, $table, $localKey, $operator, $referenceKey); return $this;
    }
public function join ( $ table , $ localKey , $ operator = null , $ referenceKey = null , $ type = 'left' ) { // validate the join type if ( ! in_array ( $ type , array ( 'inner' , 'left' , 'right' , 'outer' ) ) ) { throw new Exception ( 'Invalid join type "' . $ type . '" given. Available type: inner, left, right, outer' ) ; } // to make nested joins possible you can pass an closure // wich will create a new query where you can add your nested wheres if ( is_object ( $ localKey ) && ( $ localKey instanceof \ Closure ) ) { // create new query object $ subquery = new SelectJoin ; // run the closure callback on the sub query call_user_func_array ( $ localKey , array ( & $ subquery ) ) ; // add the join $ this -> joins [ ] = array ( $ type , $ table , $ subquery ) ; return $ this ; } $ this -> joins [ ] = array ( $ type , $ table , $ localKey , $ operator , $ referenceKey ) ; return $ this ; }
Add a join statement to the current query

->join('avatars', 'users.id', '=', 'avatars.user_id')

@param array|string              $table The table to join. (can contain an alias definition.)
@param string                    $localKey
@param string                    $operator The operator (=, !=, <, > etc.)
@param string                    $referenceKey
@param string                    $type The join type (inner, left, right, outer)

@return self The current query builder.
Add a join statement to the current query