function Select::fields

Same name in other branches
  1. 9 core/lib/Drupal/Core/Database/Query/Select.php \Drupal\Core\Database\Query\Select::fields()
  2. 8.9.x core/lib/Drupal/Core/Database/Query/Select.php \Drupal\Core\Database\Query\Select::fields()
  3. 10 core/lib/Drupal/Core/Database/Query/Select.php \Drupal\Core\Database\Query\Select::fields()

Overrides SelectInterface::fields

File

core/lib/Drupal/Core/Database/Query/Select.php, line 565

Class

Select
Query builder for SELECT statements.

Namespace

Drupal\Core\Database\Query

Code

public function fields($table_alias, array $fields = []) {
    if ($fields) {
        foreach ($fields as $field) {
            // We don't care what alias was assigned.
            $this->addField($table_alias, $field);
        }
    }
    else {
        // We want all fields from this table.
        $this->tables[$table_alias]['all_fields'] = TRUE;
    }
    return $this;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.