You are here

function getlocations_fields_handler_argument_city::query in Get Locations 7.2

Same name and namespace in other branches
  1. 7 modules/getlocations_fields/handlers/getlocations_fields_handler_argument_city.inc \getlocations_fields_handler_argument_city::query()

Set up the query for this argument.

The argument sent may be found at $this->argument.

Overrides views_handler_argument::query

File

modules/getlocations_fields/handlers/getlocations_fields_handler_argument_city.inc, line 53
getlocations_fields_handler_argument_city.inc @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL

Class

getlocations_fields_handler_argument_city
Argument handler to accept city

Code

function query($group_by = FALSE) {
  $value = FALSE;
  if ($this->options['type'] == 'city' && isset($this->argument)) {
    $value = getlocations_apoclean($this->argument);
  }
  if ($value) {
    $alias = $this->table_alias ? $this->table_alias : $this->table;
    $field = $alias . '.' . $this->real_field;
    if ($this->options['operator'] == 'equal') {
      $this->query
        ->add_where($group_by, $field, $value, 'LIKE');
    }
    elseif ($this->options['operator'] == 'not_equal') {
      $this->query
        ->add_where($group_by, $field, $value, 'NOT LIKE');
    }
    elseif ($this->options['operator'] == 'begin_with') {
      $this->query
        ->add_where($group_by, $field, db_like($value) . '%', 'LIKE');
    }
    elseif ($this->options['operator'] == 'not_begin_with') {
      $this->query
        ->add_where($group_by, $field, db_like($value) . '%', 'NOT LIKE');
    }
    elseif ($this->options['operator'] == 'end_with') {
      $this->query
        ->add_where($group_by, $field, '%' . db_like($value), 'LIKE');
    }
    elseif ($this->options['operator'] == 'not_end_with') {
      $this->query
        ->add_where($group_by, $field, '%' . db_like($value), 'NOT LIKE');
    }
    elseif ($this->options['operator'] == 'contain') {
      $this->query
        ->add_where($group_by, $field, '%' . db_like($value) . '%', 'LIKE');
    }
    elseif ($this->options['operator'] == 'not_contain') {
      $this->query
        ->add_where($group_by, $field, '%' . db_like($value) . '%', 'NOT LIKE');
    }
  }
}