I have two tables: assignment and file that is related to assignment. I would like to get rows of assignment that are related to any row of file applying the where sentence.
$querybuilder = $this->createQueryBuilder('query');
$querybuilder
->select('assignment')
->from(AssignmentReadModel::class, 'assignment')
->innerJoin('assignment.files', 'files')
->where('files.name=:archivo')
->setParameter('archivo', 'practica');
$data = $querybuilder->getQuery()->getResult();
$files = $data[0]->files();
var_export($files->count());
With this query I'm getting all the files when it should only get only one file "practica". When I execute "$files->count()" doctrine is doing a extra query to get all the files.