Foreign key fields returning null on doctrine querybuilder

I have this query:

    /**
     * @return []
     */

    public function classificacao(): array
    {
        $qb = $this->createQueryBuilder('c')
        ->select('cla')
        ->andWhere('c.ativo =1')
        ->leftJoin('App\Entity\Classificacao','cla', 'with', 'cla.cliente = c.id')
        ->orderBy('c.codigo')
        ->getQuery();

        return $qb->execute();

    }

but when i dump it the fields of the fk's entity return as null (and have value on the db):

enter image description here

if I select the 'c' Entity as well: ->select('cla, c') it works but passes the whole 'Cliente' entity again:

enter image description here

What am I doing wrong here and how I can get the return of the first image with the actual values inside the cliente field?



Read more here: https://stackoverflow.com/questions/64395592/foreign-key-fields-returning-null-on-doctrine-querybuilder

Content Attribution

This content was originally published by Lucas Marques at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: