Welcome Guest, Not a member yet? Register   Sign In
How to select data from joined table

Hi there,
I have a table and some relations in an 2nd one. My model for the first table works fine. But if I need data from this relation-table, it get Unknown column 'r.id' in 'field list'.
In detail, this is how my model is configured:
PHP Code:
    protected $table         'epoche';
    protected $primaryKey    'id';
    protected $returnType    'object';
    protected $allowedFields = ['id''slug''type''name']; 

and this is the method, I use
PHP Code:
    public function getRelationsTo($type$to$id NULL)

        $query $this->builder()
            ->select('epoche.name, epoche.slug, r.id')

        if ($to == 'below')
            $query->join('epoche_relationship as r''r.epoche_id = epoche.id')
It works fine without the r.id in select. And as I understand, it is the model, which not allows the r.id-column from the 2nd table.

So, how to select data from joined tables if the model does not allow it?


PS: I removed some data, so if there is missing something, this is not the reason of the error :-) My model works fine. But now, I need this ID and changed my model only on this little point.

Messages In This Thread
How to select data from joined table - by sprhld - 09-18-2021, 11:27 AM

Theme © iAndrew 2016 - Forum software by © MyBB