Adds some fields to the query.

@param  string|array $fields The fields.
@return string               Formatted fields list.
553390
public function fields($fields)
    {
        $fields = is_array($fields) && func_num_args() === 1 ? $fields : func_get_args();
        $this->_parts['fields'] = Set::merge($this->_parts['fields'], $fields);
        return $this;
    }
1275615
public function setFields(array $fields)
    {
        foreach ($fields as $key => $field) {
            $this->setField($key, $field);
        }

        return $this;
    }
1212972
public function setFieldsFromArray(Array $fields) {
    foreach ($fields as $field => $value) {
      $this->set($field, $value);
    }
    return $this;
  }
566194
public static function fromArray(array $fields)
    {
        $form = new static();
        foreach ($fields as $key => $field) {
            $form->addField($field, $key);
        }

        return $form;
    }
973232
private function prepareFields(array $fields)
    {
        $include = null;
        foreach ($fields as $key => $type) {
            $type = (bool) $type;
            if (null === $include) {
                $include = $type;
            }
            if ($type !== $include) {
                PersisterException::badRequest('Field projection mismatch. You cannot both exclude and include fields.');
            }
            $fields[$key] = $type;
        }
        return [$fields, $include];
    }
422914
public function addFields(array $fields)
    {
        foreach ($fields as $field)
        {
            $name = $field->getName();
            $addFields[$name] = $field; # we key by name to prevent duplicates!
        }
        
        $keysString = "";
        $fieldStrings = array();
        
        foreach ($addFields as $fieldName => $field)
        {
            $fieldStrings[] = $field->getFieldString();
                
            /* @var $field DatabaseField */
            if ($field->isPrimaryKey())
            {
                $errMsg = 'Do not set field to be primary key when adding fields. ' .
                          'Instead, use the changePrimaryKey method';
                throw new \Exception($errMsg);
            }
            elseif ($field->isKey())
            {
                if ($keysString !== "")
                {
                    $keysString .= ", ";
                }
                
                if ($field->isUnique())
                {
                    $keysString .= "UNIQUE ";
                }
                
                $keysString .= "KEY (`" . $fieldName . "`) ";
            }
        }
        
        $fieldsString = implode(", ", $fieldStrings);
        
        $fieldsString .= $keysString;
        
        $query = 
            "ALTER TABLE " . 
            "`" . $this->m_name . "` " . 
            "ADD " .
            "(" . $fieldsString . ") ";
        
        $result = $this->m_mysqliConn->query($query);
        
        if ($result !== TRUE)
        {
            throw new \Exception('Error creating table with query: ' . $query);
        }
    }
1338608
public function addField(Field ...$fields)
    {
        collect($fields)->map(function ($field) {
            $this->group['fields']->put($field->key(), $field->get());
        });

        return $this;
    }
213326
private function formatStructForApi(array $fields)
    {
        $fFields = [];

        foreach ($fields as $key => $value) {
            $fFields[$key] = $this->formatValueForApi($value);
        }

        return ['fields' => $fFields];
    }
942680
public function fields( $fields )
	{
		if ( !is_array( $fields ) && !is_null( $fields ) )
		{
			$fields = array( $fields );
		}
		
		// do nothing if we get nothing
		if ( empty( $fields ) || $fields == array( '*' ) )
		{
			$this->fields = array(); return $this;
		}
		
		$this->fields = $fields;

		// return self so we can continue running the next function
		return $this;
	}
80536
public function addFields(array $pFields)
    {
        $fields        = $this->_prefixFields($pFields);
        $this->_fields = array_merge($fields, $this->_fields);
        return $this;
    }
1002272
public function setFields(array $fields)
    {
        $this->clearFields();

        foreach ($fields as $field) {
            $this->addField($field);
        }

        return $this;
    }
1003111
public static function rows(array $fields): Rows
    {
        return new class($fields) extends Rows {
            /**
             * @var array
             */
            private $fields;

            /**
             *  constructor.
             *
             * @param array $fields
             */
            public function __construct(array $fields)
            {
                $this->fields = $fields;
            }

            /**
             * @return array
             */
            public function fields(): array
            {
                return $this->fields;
            }
        };
    }
907535
public function desc($fields) {
        if (is_array($fields)) {
            $this->_order = ' ORDER BY ' . implode($fields, ', ') . ' DESC';
        } else {
            $this->_order = ' ORDER BY ' . $fields . ' DESC';
        }
         
        return $this;
    }
1316396
public function useFields($fields)
    {
        if (is_string($fields)) {
            $fields = explode(',', $fields);
        }
        $this->fields = $fields;

        return $this;
    }
259872
private static function getFieldTypeArray($fields)
    {
        if (count($fields) === 0) {
            return;
        }

        $types = array();

        foreach ($fields as &$field) {
            $types[] = $field->type;
        }

        return $types;
    }
1173093
private function fieldPrefixer(array &$fields)
    {
        foreach ($fields as $index => $property) {
            if (0 === \strpos($property, $this->source . '.')
                || !$this->fieldExists($property)
            ) {
                continue;
            }

            $fields[$index] = $this->source . '.' . $property;
        }
    }
399886
public function add(array $fields)
    {
        $xml = "<employee>";

        foreach ($fields as $field => $value) {
            $xml .= "<field id=\"{$field}\">{$value}</field>";
        }

        $xml .= "</employee>";

        return $this->post("employees", $xml);
    }