You are here

function views_handler_field_views_raw_sql::query in Views Raw SQL 7

Same name and namespace in other branches
  1. 6 views_handler_field_views_raw_sql.inc \views_handler_field_views_raw_sql::query()

Called to add the field to a query.

Overrides views_handler_field::query

File

./views_handler_field_views_raw_sql.inc, line 10

Class

views_handler_field_views_raw_sql
A handler to provide a field 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, $this->options['id']);

  // And replace.
  $raw_sql = str_replace(array_keys($tokens), $tokens, $raw_sql);
  $params = $this->options['group_type'] != 'group' ? array(
    'function' => $this->options['group_type'],
  ) : array();
  $this->field_alias = $this->query
    ->add_field(NULL, $raw_sql, 'raw_sql_field', $params);
}