You are here

function timefield_handler_sort_timefield_duration::query in Timefield 7

Called to add the sort to a query.

Overrides views_handler_sort::query

File

views/timefield_handler_sort_timefield_duration.inc, line 8
Contains the duration field handler.

Class

timefield_handler_sort_timefield_duration
@file Contains the duration field handler.

Code

function query() {
  $this
    ->ensure_my_table();

  // Get the Field API field name from the definition.
  $field_name = $this->definition['field_name'];

  // Create our formula: value2 - value is the duration in seconds.
  $formula = $field_name . '_value2' . ' - ' . $field_name . '_value';

  // Add our expression to the query.
  $this->query
    ->add_orderby(NULL, $formula, $this->options['order'], $this->table_alias . '_duration');
}