symfony2 createQueryBuilder symfony2 createQueryBuilder symfony symfony

symfony2 createQueryBuilder


Technically in the eyes of Doctrine ORM the cursoAcademico_id field doesn't exist. It is used to create a link between the 2 tables to create the object but you can't use it in anything.

To do a search for an object with the given id you should use a join and match the id of the joined object like..

$q=$this->createQueryBuilder('a')    // Create builder in 'Adjudicacion' repository so 'a' rather than 'c'    ->join('a.cursoAcademico', 'c')    // Join 'Adjudicacion' to 'CursoAcademico'    ->where('c.id = :cursoAcademico_id')    // match id of joined `CursoAcademico`    ->setParameter('cursoAcademico_id', $cursoAcademicoActual)    ->getQuery()->getResult();return $q;