function SelectInterface::fields

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

Add multiple fields from the same table to be SELECTed.

This method does not return the aliases set for the passed fields. In the majority of cases that is not a problem, as the alias will be the field name. However, if you do need to know the alias you can call getFields() and examine the result to determine what alias was created. Alternatively, simply use addField() for the few fields you care about and this method for the rest.

Parameters

$table_alias: The name of the table from which the field comes, as an alias. Generally you will want to use the return value of join() here to ensure that it is valid.

$fields: An indexed array of fields present in the specified table that should be included in this query. If not specified, $table_alias.* will be generated without any aliases.

Return value

$this The called object.

2 methods override SelectInterface::fields()
Select::fields in core/lib/Drupal/Core/Database/Query/Select.php
SelectExtender::fields in core/lib/Drupal/Core/Database/Query/SelectExtender.php

File

core/lib/Drupal/Core/Database/Query/SelectInterface.php, line 221

Class

SelectInterface
Interface definition for a Select Query object.

Namespace

Drupal\Core\Database\Query

Code

public function fields($table_alias, array $fields = []);

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