You are here

function views_calc_field_handler::query in Views Calc 6

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

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

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();
  while ($calc_field = db_fetch_array($results)) {
    if ($this->definition['cid'] == $calc_field['cid']) {
      foreach (explode(',', $calc_field['tablelist']) as $table) {
        $this->view->query
          ->add_table($table);
      }
      $this->view->query
        ->add_field(NULL, "({$calc_field['calc']})", "cid" . $calc_field['cid']);
      return;
    }
  }
}