You are here

public function date_views_argument_handler::query in Date 7.2

Same name and namespace in other branches
  1. 8 date_views/includes/date_views_argument_handler.inc \date_views_argument_handler::query()
  2. 7.3 date_views/includes/date_views_argument_handler.inc \date_views_argument_handler::query()
  3. 7 date_views/includes/date_views_argument_handler.inc \date_views_argument_handler::query()

Build the query based upon the formula

Overrides date_views_argument_handler_simple::query

File

date_views/includes/date_views_argument_handler.inc, line 152
Date API views argument handler.

Class

date_views_argument_handler
Date API argument handler.

Code

public function query($group_by = FALSE) {

  // @todo Not doing anything with $group_by yet, need to figure out what has
  // to be done.
  if ($this
    ->date_forbid()) {
    return;
  }
  $this
    ->get_query_fields();
  $this->query
    ->set_where_group($this->options['date_method'], $this->options['date_group']);
  $this->granularity = $this->date_handler
    ->arg_granularity($this->argument);
  $format = $this->date_handler
    ->views_formats($this->granularity, 'sql');
  $this->placeholders = array();
  if (!empty($this->query_fields)) {

    // Use set_where_group() with the selected date_method of 'AND' or 'OR'
    // to create the where clause.
    foreach ($this->query_fields as $count => $query_field) {
      $field = $query_field['field'];
      $this->date_handler = $query_field['date_handler'];
      $this->field = $field['field_name'];
      $this->real_field = $field['field_name'];
      $this->table = $field['table_name'];
      $this->original_table = $field['table_name'];
      if ($field['table_name'] != $this->table || !empty($this->relationship)) {
        $this->table = $this->query
          ->ensure_table($field['table_name'], $this->relationship);
      }
      elseif (empty($this->relationship)) {
        $this->table_alias = NULL;
      }
      parent::query($group_by);
      $this->placeholders = array_merge($this->placeholders, $this->date_handler->placeholders);
    }
  }
}