Lazer\Classes\Core_Relation::join PHP Method

join() protected method

Process query with joined data
protected join ( object $row ) : Lazer\Classes\Database
$row object One row of data
return Lazer\Classes\Database
    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 array();
            }
            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']});
    }