You are here

function views_calc_query_handler in Views Calc 5

Query handler to update query use handler insert a real field with the calc into the query

1 string reference to 'views_calc_query_handler'
views_calc_views_tables in ./views_calc.module
Implementation of hook_views_tables.

File

./views_calc.module, line 431
This module will allow you to add calculated fields to views tables and compute (SUM, COUNT, AVG, etc) columns of numeric data in a views table.

Code

function views_calc_query_handler(&$field, &$fieldinfo, &$query) {
  $results = _views_calc_fields();
  while ($calc_field = db_fetch_array($results)) {
    if ($fieldinfo['cid'] == $calc_field['cid']) {
      foreach (explode(',', $calc_field['tablelist']) as $table) {
        $query
          ->ensure_table($table);
      }
      $query
        ->add_field("(" . $calc_field['calc'] . ") AS _cid" . $calc_field['cid'], NULL);
    }
  }
}