=====
Setup:
=====

$where = "
                Product.city_id = '".$city_id."'
                GROUP BY Subproduct.id ORDER BY Product.id ASC";

$fields = array(
                'Product.id',
                'Product.name',
                'Product.description',
                'Product.main_image',
                'Subproduct.id',
                'MIN(Rate.dly_pp_one_adults) AS min_rate',
                'Unavailability.from_date',
                'Unavailability.to_date',
                "'2007-02-12' BETWEEN Unavailability.from_date AND
Unavailability.to_date AS
available"
                );

$results = $this->Subproduct->findAll($where,$fields,null,null,null,1);

===========
Cake produces:
===========

SELECT `Product`.`id`, `Product`.`name`, `Product`.`description`,
`Product`.`main_image`, `Subproduct`.`id`, MIN(Rate.dly_pp_one_adults)
AS min_rate, `Unavailability`.`from_date`, `Unavailability`.`to_date`,
`'2007-02-12' BETWEEN Unavailability`.`from_date AND Unavailability`
FROM `subproducts` AS `Subproduct` LEFT JOIN `products` AS `Product` ON
`Subproduct`.`product_id` = `Product`.`id` LEFT JOIN `unavailabilities`
AS `Unavailability` ON `Unavailability`.`subproduct_id` =
`Subproduct`.`id` LEFT JOIN `rates` AS `Rate` ON `Rate`.`subproduct_id`
= `Subproduct`.`id` WHERE `Product`.`city_id` = '1' GROUP BY
`Subproduct`.`id` ORDER BY `Product`.`id` ASC

You can see it cuts off the BETWEEN expression prematurely:

from:
--------

"'2007-02-12' BETWEEN Unavailability.from_date AND
Unavailability.to_date AS
available"

to:
-----
`'2007-02-12' BETWEEN Unavailability`.`from_date AND Unavailability`


It also mistakenly thinks `from_date AND Unavailability` is the table's
field name, rather than just from_date.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to