public function Analytic::getPropertyValues in Analytics 6
Return all known values for a property.
File
- includes/
analytic.inc, line 254 - Class definition for analytics.
Class
- Analytic
- @file Class definition for analytics.
Code
public function getPropertyValues($property_name, $count = FALSE) {
$query = db_select('analytics_property_values', 'apv')
->fields('apv', array(
'value',
))
->distinct(TRUE);
$query
->join('analytics_properties', 'ap', 'apv.property_id = ap.id AND ap.property_name = :name', array(
':name' => $property_name,
));
$query
->join('analytics_event_instance', 'aei', 'apv.event_instance_id = aei.id AND aei.event_id = :event_id', array(
':event_id' => $this->event_id,
));
if ($count) {
$query
->addExpression('COUNT(DISTINCT apv.value)', 'count');
$result = $query
->execute()
->fetch();
return $result->count;
}
$result = $query
->execute();
$values = array();
foreach ($result as $item) {
$values[] = $item->value;
}
return $values;
}