Re: Containable Aggregate Fields Problem

2010-05-18 Thread Peter Krutz
Thanks for the info! I'm glad you mentioned the afterSave technique, I was using that for the overall rating average. What I was trying to do was grab the ratings posted in the past month and average from there. That seems a bit intensive, just going with the afterSave for now. On Thu, May 13, 201

Re: Containable Aggregate Fields Problem

2010-05-13 Thread WebbedIT
I have not done any work within Cake using GROUP BY, AVG or SUM etc yet but immediately it strikes me that your running this query on the wrong model and not GROUPing your results to allow it to return any meaningful AVGs. If you set debug to 2 and look at the queries being generated you will see

Containable Aggregate Fields Problem

2010-05-12 Thread emptywalls
I've got a Songs model, and each song HasMany Rating. I want to query for a list of songs, and get the average Rating. $this->Song->find('all', array( 'fields' => 'Song.title', 'contain' => array(Rating => array( 'fields' => array(AVG(Rating.value) as rating_averag