You are here

public function date_views_argument_handler_simple::summary_query in Date 7.2

Same name and namespace in other branches
  1. 8 date_views/includes/date_views_argument_handler_simple.inc \date_views_argument_handler_simple::summary_query()
  2. 7.3 date_views/includes/date_views_argument_handler_simple.inc \date_views_argument_handler_simple::summary_query()

Build the summary query based on a formula

Overrides views_handler_argument_formula::summary_query

File

date_views/includes/date_views_argument_handler_simple.inc, line 262
Date API views argument handler.

Class

date_views_argument_handler_simple
Date API views argument handler.

Code

public function summary_query() {

  // Inject a test for valid date range before the summary query.
  // @todo The summary values are computed by the database. Unless the
  // database has built-in timezone handling it will use a fixed offset,
  // which will not be right for all dates. The only way I can see to make
  // this work right is to store the offset for each date in the database so
  // it can be added to the base date value before the database formats the
  // result. Because this is a huge architectural change, it won't go in
  // until we start a new branch.
  $this->formula = $this->date_handler
    ->sql_format($this->sql_format, $this->date_handler
    ->sql_field("***table***.{$this->real_field}"));
  $this
    ->ensure_my_table();

  // Now that our table is secure, get our formula.
  $formula = $this
    ->get_formula();

  // Add the field, give it an alias that does NOT match the actual field
  // name or grouping won't work right.
  $this->base_alias = $this->name_alias = $this->query
    ->add_field(NULL, $formula, $this->field . '_summary');
  $this->query
    ->set_count_field(NULL, $formula, $this->field);
  return $this
    ->summary_basics(FALSE);
}