You are here

function _views_query::add_field in Views (for Drupal 7) 5

1 call to _views_query::add_field()
_views_query::add_orderby in ./views_query.inc

File

./views_query.inc, line 312

Class

_views_query

Code

function add_field($field, $table = '$$', $alias = '') {
  if ($table == '$$') {

    // I picked $$ because it's not a legal name for a table and NULL is
    // actually a valid possibility here, and I can't default to a variable.
    $table = $this->primary_table;
  }

  // We check for this specifically because we don't want to add it aliased.
  if ($table == $this->primary_table && $field == $this->primary_field) {
    return;
  }
  if ($table) {
    $this
      ->ensure_table($table);
    $table = $this->use_alias_prefix . $table . ".";
  }
  if ($alias) {
    $a = " AS {$this->use_alias_prefix}{$alias}";
  }
  if (!in_array("{$table}{$field}{$a}", $this->fields)) {
    $this->fields[] = "{$table}{$field}{$a}";
  }
}