I am working with Doctrine 1.2 in Symfony 1.4 on PHP5.3.
I have a database in which events have several start dates (1: n) and types (n: m).
For the program, I need a list of starting times and an event header, which are of a special type and are not out of date:
$dql = Doctrine_Query::create()
->select('ed.start_datetime,e.title')
->from('EventDate ed')
->leftJoin('ed.Event e')
->leftJoin('e.EventTypes et')
->leftJoin('e.Domain d')
->orderBy('ed.start_datetime, ed.event_id');
->where('e.start_datetime >= ? AND e3.id = ?',array('2011-05-27 17:19:41',2))
->fetchArray();
The schema can be reviewed at pastebin.com/SdjvsaxW .
Now, the doctrine makes two statements
SELECT DISTINCT e5.event_id FROM event_date e5 LEFT JOIN event e6 ON e5.event_id = e6.id LEFT JOIN event_event_type e8 ON (e6.id = e8.event_id) LEFT JOIN event_type e7 ON e7.id = e8.event_type_id WHERE (e5.start_datetime >= '2011-05-27 17:19:41' AND e7.id = '2') ORDER BY e5.start_datetime, e5.event_id
SELECT e.event_id AS e__event_id, e.start_datetime AS e__start_datetime, e2.id AS e2__id, e2.title AS e2__title FROM event_date e LEFT JOIN event e2 ON e.event_id = e2.id LEFT JOIN event_event_type e4 ON (e2.id = e4.event_id) LEFT JOIN event_type e3 ON e3.id = e4.event_type_id WHERE e.event_id IN (*all the IDs from the first query*) AND (e.start_datetime >= '2011-05-27 17:19:41' AND e3.id = '2') ORDER BY e.start_datetime, e.event_id
: , . , , SELECT DISTINCT . , . 50 , , 51-100, , , (- ).
, , , .
?