I am writing an app in CakePHP and need to get a count of posts for an image. its a one (image) to many (comments) link.
I have tried the following but it doesnt work as it cant find the table? I know I have managed to do this with just SQL queries in previous applications.
This is the code
$data = $this->Image->find('all', array(
'fields' => array('COUNT(Comment.comment_id) AS total', 'Image.*'),
'group' => array('Image.logo_id')
));
basically I want to output the image details and then a comment count which is associated to the image.
Hope someone can help.
Thanks.