php - Doctrine 2: Combine Select with Select from another table with identical structure
In my Symfony application in which I use Doctrine 2 I have two tables: APPOINTMENTS and APPOINTMENTS_ARCHIVED. Both tables have an identical (!) structure with identical fields!
My function in my AppointmentsRepository:
private function getAppointments()
{
$qb = $this->createQueryBuilder('a');
$qb->leftJoin('a.instructor', 'i')
->leftJoin('i.contactdetails', 'c')
->join('a.area', 'ar');
return $qb;
}
This repository points to my table APPOINTMENTS.
How can I add a select of data in APPOINTMENTS_ARCHIVED to this query? My goal is that my query does not only consider data in my table APPOINTMENTS, but in addition data in my table with archived data APPOINTMENTS_ARCHIVED.
Answer
Solution:
I assume that your
APPOINTMENTS_ARCHIVED
table is an archived version of theAPPOINTMENTS
table ?This means that the archived table is not mapped to an entity, therefore impossible to get with DQL
Your best bet would be to to user Native SQL.
Answer
Solution:
You can select multiple entities without them been related. In this case:
You have to join and select the relations separately in this case.