My code:
$this->Vendor->bindModel(array('hasOne'=>array('Model')));
$fields = array('Vendor.name', 'COUNT(Model.vendor_id) AS
`Vendor`.`count`');
$conditions = 'GROUP BY Vendor.id';
$order = 'Vendor.name ASC';
$result = $this->Vendor->findAll($conditions, $fields, $order);SQL: 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 Error message: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.count FROM `vendors` AS `Vendor` LEFT JOIN `model` MySQL version: 4.1.16, PHP version: 4.4.4 On Apr 30, 7:26 pm, "Mariano Iglesias" <[EMAIL PROTECTED]> wrote: > Can you show how you are issuing the query? > > I added a test to test for field parsing as you entered here and it > succeeds: > > https://trac.cakephp.org/changeset/4951 > > -MI > > --------------------------------------------------------------------------- > > Remember, smart coders answer ten questions for every question they ask. > So be smart, be cool, and share your knowledge. > > BAKE ON! > > blog:http://www.MarianoIglesias.com.ar > > -----Mensaje original----- > De: [email protected] [mailto:[EMAIL PROTECTED] En nombre > de Alexey Kuimov > Enviado el: Lunes, 30 de Abril de 2007 10:13 a.m. > Para: Cake PHP > Asunto: Re: Question: Join two tables, count and sort result > > In this case I get error message: > > 1064: You have an error in your SQL syntax; check the manual that > corresponds to your MySQL server version for the right syntax to use > near '.`count` > > :-( --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
