0
It is possible to perform a query with Doctrine createQueryBuilder using a table that does not have a declared entity (Entity)?
Example: In the code below table table2 (t2) does not have an entity created, because it is a relationship table and only has the relation fields.
$this->createQueryBuilder('t1')
->select(['t1', 't2.id'])
->leftJoin('table2', 't2', 'ON', 't1.id = t2.id')
->andWhere('t2.id IS NOT NULL')
->getQuery()
->getResult();
When it’s relationship you don’t even need to do a custom query, just give a get of the property in Entity. But if for some reason it is necessary you just put in select to return t1.t2 ( where t2 is the name of the property in Entity t1).
– fajuchem