You are here

function timefield_handler_field_timefield_duration::query in Timefield 7

Called to add the field to a query.

Overrides views_handler_field::query

File

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

Class

timefield_handler_field_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->name_alias = $this->query
    ->add_field(NULL, $formula, $this->table_alias . '_duration');
}