It's strange, but I still get that error message :(. I added backticks, I tried to use `Vendor`.`total` instead `Vendor`.`count` with same negative result. Please, help me with code in controller. Now I'm using this:
$this->Vendor->bindModel(array('hasOne'=>array('Model'))); $fields = array('Vendor.name', 'Vendor.safe', 'COUNT(Model.vendor_id) AS `Vendor`.`count`'); $conditions = 'GROUP BY Vendor.id'; $order = 'Vendor.name ASC'; $result = $this->Vendor->findAll($conditions, $fields, $order); On May 6, 5:32 pm, geoffriley <[EMAIL PROTECTED]> wrote: > You need to quote with backticks the `Vendor`.`count`. > > Without the backticks the SQL interpreter thinks that you're > attempting to use the function count() again, so it's expecting > something to count but finds 'FROM' instead: hence the error. > > So, make your SQL like this, and you should be okay: > > SELECT > `Vendor`.`name`, > `Vendor`.`safe`, > COUNT(Model.vendor_id) AS `Vendor`.`count` > FROM > `vendors` AS `Vendor` > LEFT JOIN `models` AS `Model` ON `Model`.`vendor_id` = `Vendor`.`id` > GROUP BY `Vendor`.`id` > ORDER BY `Vendor`.`name` ASC > > As an aside, I think you can safely replace > ON `Model`.`vendor_id` = `Vendor`.`id` > with > USING (`id`) > given that only two tables are involved. But I could be wrong on that > one. :-) > > Hope that helps. > > Geoff --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---