public function view_custom_table_handler_sort_date::query in Views Custom Table 7
Called to add the sort to a query.
Overrides views_handler_sort::query
File
- views/
handlers/ view_custom_table_handler_sort_date.inc, line 54 - Definition of views_handler_sort_date.
Class
- view_custom_table_handler_sort_date
- Basic sort handler for dates.
Code
public function query() {
$this
->ensure_my_table();
switch ($this->options['granularity']) {
case 'second':
default:
$this->query
->add_orderby($this->table_alias, $this->real_field, $this->options['order']);
return;
case 'minute':
$formula = views_date_sql_format('YmdHi', "{$this->table_alias}.{$this->real_field}");
break;
case 'hour':
$formula = views_date_sql_format('YmdH', "{$this->table_alias}.{$this->real_field}");
break;
case 'day':
$formula = views_date_sql_format('Ymd', "{$this->table_alias}.{$this->real_field}");
break;
case 'month':
$formula = views_date_sql_format('Ym', "{$this->table_alias}.{$this->real_field}");
break;
case 'year':
$formula = views_date_sql_format('Y', "{$this->table_alias}.{$this->real_field}");
break;
}
// Add the field.
$this->query
->add_orderby(NULL, $formula, $this->options['order'], $this->table_alias . '_' . $this->field . '_' . $this->options['granularity']);
}