I just can't get this to work. I need to see how many tasks each
project has. The following kicks out an error.
$this->Project-
>bindModel(array('hasOne'=>array('Task'=>array('className'=>'Task','foreign_key'=>'project_id'))));
$fields = array('Project.id','count(`Task`.`project_id`)');
$conditions = "`Project`.`company_id`= `3` GROUP BY
`Task`.`project_id`";
$result = $this->Project->findAll($conditions,$fields);
pr($result);
Here is the query that gets generated.
SELECT `Project`.`id`, count(`Task`.`project_id`) FROM `projects` AS
`Project` LEFT JOIN `tasks` AS `Task` ON (`Project`.`company_id`= `3`
GROUP BY `Task`.`project_id` AND `Task`.`project_id` = `Project`.`id`)
WHERE `Project`.`company_id`= `3` GROUP BY `Task`.`project_id`
Here is the error.
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 'GROUP BY `Task`.`project_id` AND `Task`.`project_id` =
`Project`.`id`) WHERE `' at line 1
Thanks in advance for any help.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---