Yii - SQL Query with having issue
I have a table with column date_reservation
When I use simple SQL query function to get the total items between two dates using HAVING, it results correctly but when I use model of that table and set the criteria using CDBCriteria it says that column date_reservation defined in having clue does not exist.
Here is my SQL Query
SELECT *
FROM `booking`
WHERE id_domain='1'
AND lang='fr'
HAVING date_reservation >'2011-06-06 00:00:00'
AND date_reservation< '2011-06-10 00:00:00'
and Here is Query Generated by CDBCriteria
Error in querying SQL: SELECT COUNT(*) FROM
booking
t
WHERE id_domain='1' AND lang='fr' HAVING date_reservation >'2011-06-08 00:00:00' AND date_reservation <开发者_如何转开发;'2011-06-10 00:00:00'
Any help?
There is a difference between SELECT *
and SELECT COUNT(*)
.
When using SELECT COUNT(*)
, date_reservation
hasn't been included in the query.
精彩评论