function visitors_hours_data in Visitors 7.2
Same name and namespace in other branches
- 8 reports/hours.inc \visitors_hours_data()
- 7 reports/hours.inc \visitors_hours_data()
- 7.0 reports/hours.inc \visitors_hours_data()
Get data for hours report order the query based on a header array.
Parameters
header: Table header array. If header is NULL - data is not sorted.
Return value
hours data array
2 calls to visitors_hours_data()
- chart_visitors_hours in reports/
hours.inc - Display hours chart report.
- visitors_hours in reports/
hours.inc - Display hours report.
File
- reports/
hours.inc, line 17 - Hours report for the visitors module.
Code
function visitors_hours_data($header) {
$query = db_select('visitors', 'v');
$query
->addExpression('COUNT(*)', 'count');
$query
->addExpression(visitors_date_format_sql('visitors_date_time', '%H'), 'hour');
visitors_date_filter_sql_condition($query);
$query
->groupBy('hour');
if (!is_null($header)) {
$query
->extend('TableSort')
->orderByHeader($header);
}
return $query
->execute();
}