You are here

function views_calc_field_handler::query in Views Calc 7

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

Find the right calculation and add it to the query as an aliased field.

Overrides views_handler_field::query

File

./views_calc_field_handler.inc, line 55
Copied from the basic 'node' field handler.

Class

views_calc_field_handler
Field handler to provide simple renderer that allows linking to a node.

Code

function query() {
  $results = _views_calc_fields();
  foreach ($results as $calc_field) {
    if ($this->definition['cid'] == $calc_field->cid) {

      // Ensure that the expected tables and fields have been joined in.
      foreach (explode(',', $calc_field->fieldlist) as $field) {
        $parts = explode('.', $field);

        //$this->view->query->add_field($parts[0], $parts[1]);
        $this->view->query
          ->add_table($parts[0]);
      }
      $this->view->query
        ->add_field(NULL, "({$calc_field->calc})", "cid" . $calc_field->cid);
    }
  }
}