My program generates this DQL using echo $q->getDql(); reformated for easier reading:
SELECT o.*, t.*, COUNT(t.id) AS num_of_reservations
FROM Property o
LEFT JOIN o.Reservation t
WITH t.status=? AND
( (t.start_date<=? AND t.end_date>=?)
OR (t.start_date>=? AND t.start_date <= ?) )
GROUP BY o.id
HAVING num_of_reservations < o.nr_of_bookings
Using PHP unit tests, I get results as expected. However, when I send this Doctrine_Query to Doctrine_Pager, I get this error:
Fatal error: Uncaught exception 'Doctrine_Connection_Mysql_Exception' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'p.nr_of_bookings' in 'having clause'
I tried all combinations like using having('COUNT(t.id)..... ) etc, different SELECT combos, all results picked by $q->execute() are good except when I send it to pager.
Can somebody help me with this? I even tried
FROM Property p
instead of
FROM Property o
no difference at all.