Returns a list of non-aggregates to be added to the "group by" clause.
Non-aggregates are fields that have no aggregation function (count, sum, etc) applied. Since the SQL standard requires all fields to either have an aggregation function applied, or to be in the GROUP BY clause, Views gathers those fields and adds them to the GROUP BY clause.
array An array of the fieldnames which are non-aggregates.
function get_non_aggregates() {
$non_aggregates = array();
foreach ($this->fields as $field) {
$string = '';
if (!empty($field['table'])) {
$string .= $field['table'] . '.';
}
$string .= $field['field'];
$fieldname = !empty($field['alias']) ? $field['alias'] : $string;
if (!empty($field['count'])) {
// Retained for compatibility.
$field['function'] = 'count';
}
if (!empty($field['function'])) {
$this->has_aggregate = TRUE;
}
elseif (empty($field['table'])) {
$non_aggregates[] = $fieldname;
}
elseif (empty($field['aggregate'])) {
$non_aggregates[] = $fieldname;
}
if ($this->get_count_optimized) {
// We only want the first field in this case.
break;
}
}
return $non_aggregates;
}