protected function join($row)
    {
        $keys['local']   = $this->keys['local'];
        $keys['foreign'] = $this->keys['foreign'];

        if ($this->relationType == 'hasAndBelongsToMany')
        {
            $join = Database::table($this->getJunction())
                    ->groupBy($this->tables['local'] . '_id')
                    ->where($this->tables['local'] . '_id', '=', $row->{$keys['local']})
                    ->findAll()
                    ->asArray(null, $this->tables['foreign'] . '_id');


            if (empty($join))
                return [];

            return Database::table($this->tables['foreign'])
                            ->where($keys['foreign'], 'IN', $join[$row->{$keys['local']}]);
        }

        return Database::table($this->tables['foreign'])
                        ->where($keys['foreign'], '=', $row->{$keys['local']});
    }
protected function join($row)
    {
        $keys['local']   = $this->keys['local'];
        $keys['foreign'] = $this->keys['foreign'];

        if ($this->relationType == 'hasAndBelongsToMany')
        {
            $join = Database::table($this->getJunction())
                    ->groupBy($this->tables['local'] . '_id')
                    ->where($this->tables['local'] . '_id', '=', $row->{$keys['local']})
                    ->findAll()
                    ->asArray(null, $this->tables['foreign'] . '_id');


            if (empty($join))
                return [];

            return Database::table($this->tables['foreign'])
                            ->where($keys['foreign'], 'IN', $join[$row->{$keys['local']}]);
        }

        return Database::table($this->tables['foreign'])
                        ->where($keys['foreign'], '=', $row->{$keys['local']});
    }
protected function join ( $ row ) { $ keys [ 'local' ] = $ this -> keys [ 'local' ] ; $ keys [ 'foreign' ] = $ this -> keys [ 'foreign' ] ; if ( $ this -> relationType == 'hasAndBelongsToMany' ) { $ join = Database :: table ( $ this -> getJunction ( ) ) -> groupBy ( $ this -> tables [ 'local' ] . '_id' ) -> where ( $ this -> tables [ 'local' ] . '_id' , '=' , $ row -> { $ keys [ 'local' ] } ) -> findAll ( ) -> asArray ( null , $ this -> tables [ 'foreign' ] . '_id' ) ; if ( empty ( $ join ) ) return [ ] ; return Database :: table ( $ this -> tables [ 'foreign' ] ) -> where ( $ keys [ 'foreign' ] , 'IN' , $ join [ $ row -> { $ keys [ 'local' ] } ] ) ; } return Database :: table ( $ this -> tables [ 'foreign' ] ) -> where ( $ keys [ 'foreign' ] , '=' , $ row -> { $ keys [ 'local' ] } ) ; }
Process query with joined data
@param object $row One row of data
@return Database
Process query with joined data