You are here

function views_handler_filter_views_raw_sql::query in Views Raw SQL 7

Add this filter to the query.

Due to the nature of fapi, the value and the operator have an unintended level of indirection. You will find them in $this->operator and $this->value respectively.

Overrides views_handler_filter::query

File

./views_handler_filter_views_raw_sql.inc, line 10

Class

views_handler_filter_views_raw_sql
A handler to provide a filter that is completely custom SQL by the administrator.

Code

function query() {
  $raw_sql = $this->options['raw_sql'];

  // Get replacement tokens.
  $tokens = views_raw_sql_get_query_tokens($this->view);

  // And replace.
  $raw_sql = str_replace(array_keys($tokens), $tokens, $raw_sql);
  $this
    ->ensure_my_table();
  if (!empty($this->options['raw_sql_use_having'])) {
    $this->query
      ->add_having_expression($this->options['group'], $raw_sql);
  }
  else {
    $this->query
      ->add_where_expression($this->options['group'], $raw_sql);
  }
}