Set, get or reset fields option for query.
Usage: {{{ // to add a field $query->fields('created'); }}} {{{ // to add several fields $query->fields(array('title','body','modified')); }}} {{{ // to reset fields to none $query->fields(false); // should be followed by a 2nd call to fields with required fields }}}

Parameters

  • mixed $fields string, array or `false`
  • boolean $overwrite If `true`, existing fields will be removed before adding `$fields`.

Returns

array Returns an array containing all fields added to the query.

Source

						public function fields($fields = null, $overwrite = false) {
		if ($fields === false || $overwrite) {
			$this->_config['fields'] = array();
		}
		$this->_config['fields'] = (array) $this->_config['fields'];

		if (is_array($fields)) {
			$this->_config['fields'] = array_merge($this->_config['fields'], $fields);
		} elseif ($fields && !isset($this->_config['fields'][$fields])) {
			$this->_config['fields'][] = $fields;
		}
		if ($fields !== null) {
			return $this;
		}
		return $this->_config['fields'];
	}