/** * Update rating_average and rating_count from rating data. * Note: Does not store the change! * * @return bool False if no rating data was returned so no updates could be done */ function updateFromRatingData() { $custom = array(array('operation' => 'count( id )', 'name' => 'rating_count'), array('operation' => 'avg( rating )', 'name' => 'rating_average')); $cond = array('contentobject_id' => $this->attribute('contentobject_id'), 'contentobject_attribute_id' => $this->attribute('contentobject_attribute_id')); $data = self::fetchObjectList(ezsrRatingDataObject::definition(), array(), $cond, null, null, false, false, $custom); if (isset($data[0]['rating_average'])) { $this->setAttribute('rating_average', $data[0]['rating_average']); $this->setAttribute('rating_count', $data[0]['rating_count']); return true; } return false; }