Añade un campo para realizar una busqueda plana por un valor
@param type $queryField
@param array $fields
181706
public function addQueryField($queryField,array $fields) {
        $valueField = $this->criteria->remove($queryField);
        if($valueField !== null){
            $this->addFieldLike($fields,$valueField);
        }
        return $this;
    }
823780
public function field($field, $alias = null) {
        if (is_string($field)) {
            $fields = explode(',', trim($field));
            foreach ($fields as $field) {
                $this->fields [] = Condition::cleanField($field . ($alias ? ' AS ' . $alias : ''));
            }
        } else if ($field instanceof Query) {
            if ($alias) {
                $field->alias($alias);
            }
            $this->fields [] = $field;
        } else if ($field instanceof ImmutableValue) {
            if ($alias) {
                $field->alias($alias);
            }
            $this->fields [] = $field;
        }

        return $this;
    }
511057
public function exists($fields)
    {
        $fields = is_array($fields) ? $fields : [$fields];

        foreach ($fields as $field) {
            $query = new ExistsQuery($field);

            $this->append($query);
        }

        return $this;
    }
1246422
public function setFields($fields)
    {
        if ($fields instanceof RecordFields) {
            $this->fields = $fields;
        } else {
            if (is_array($fields)) {
                $fields       = new RecordFields($fields);
                $this->fields = $fields;
            }
        }
        return $this;
    }
408387
public function includeField(Field $field, array $previousValues)
    {
        foreach ($field->getConditions() as $previousField => $condition) {
            $previousFieldObject = $this->getField($previousField);
            if ($previousFieldObject === false
                || !isset($previousValues[$previousField])
                || !$previousFieldObject->matchesCondition($previousValues[$previousField], $condition)) {
                return false;
            }
        }

        return true;
    }
1112450
protected function createCursor(array $fields = [])
    {
        if ($this->hasPaginator()) {
            $paginator = $this->getPaginator(true);

            //Paginate in isolation
            $selector = clone $this;
            $selector->limit($paginator->getLimit())->offset($paginator->getOffset());
            $options = $selector->createOptions();
        } else {
            $options = $this->createOptions();
        }

        if (!empty($fields)) {
            $options['projection'] = array_fill_keys($fields, 1);
        }

        return $this->collection->find($this->query, $options);
    }
1277490
public function addQueryFields($fields)
    {
        /** @var DMSDocument $doc */
        $doc = singleton('DMSDocument');
        /** @var FormField $field */
        $dmsDocFields = $doc->scaffoldSearchFields(array('fieldClasses' => true));
        $membersMap = Member::get()->map('ID', 'Name')->toArray();
        asort($membersMap);

        foreach ($dmsDocFields as $field) {
            if ($field instanceof ListboxField) {
                $map = ($field->getName() === 'Tags__ID') ? $doc->getAllTagsMap() : $membersMap;
                $field->setMultiple(true)->setSource($map);

                if ($field->getName() === 'Tags__ID') {
                    $field->setRightTitle(
                        _t(
                            'DMSDocumentSet.TAGS_RIGHT_TITLE',
                            'Tags can be set in the taxonomy area, and can be assigned when editing a document.'
                        )
                    );
                }
            }
        }
        $keyValPairs = DMSJsonField::create('KeyValuePairs', $dmsDocFields->toArray());

        // Now lastly add the sort fields
        $sortedBy = FieldGroup::create('SortedBy', array(
            DropdownField::create('SortBy', '', array(
                'LastEdited'  => 'Last changed',
                'Created'     => 'Created',
                'Title'       => 'Document title',
            ), 'LastEdited'),
            DropdownField::create(
                'SortByDirection',
                '',
                array(
                    'DESC' => _t('DMSDocumentSet.DIRECTION_DESCENDING', 'Descending'),
                    'ASC' => _t('DMSDocumentSet.DIRECTION_ASCENDING', 'Ascending')
                ),
                'DESC'
            ),
        ));

        $sortedBy->setTitle(_t('DMSDocumentSet.SORTED_BY', 'Sort the document set by:'));
        $fields->addFieldsToTab(
            'Root.QueryBuilder',
            array(
                LiteralField::create(
                    'GridFieldNotice',
                    '<p class="message warning">' . _t(
                        'DMSDocumentSet.QUERY_BUILDER_NOTICE',
                        'The query builder provides the ability to add documents to a document set based on the ' .
                        'filters below. Please note that the set will be built using this criteria when you save the ' .
                        'form. This set will not be dynamically updated (see the documentation for more information).'
                    ) . '</p>'
                ),
                $keyValPairs,
                $sortedBy
            )
        );
    }
340108
public function select($fields=null)
    {
        if (func_num_args() > 1) {
            $fields = func_get_args();
        }
        $this->getQuery()->type('select')->fields($fields);
        return $this;
    }
522386
public function groupBy($field): QueryBuilderInterface
	{
		if ( ! is_scalar($field))
		{
			$newGroupArray = array_map([$this->driver, 'quoteIdent'], $field);
			$this->state->setGroupArray(
				array_merge($this->state->getGroupArray(), $newGroupArray)
			);
		}
		else
		{
			$this->state->appendGroupArray($this->driver->quoteIdent($field));
		}

		$this->state->setGroupString(' GROUP BY ' . implode(',', $this->state->getGroupArray()));

		return $this;
	}
460126
public function with(...$fields) {
        foreach ($fields as $f) {
            $this->eagerFields[ $f ] = $f;
        }

        return $this;
    }
428052
public function fields($fields)
    {
        if (!is_array($fields)) {
            $fields = func_get_args();
        }

        $this->fields = array_merge($this->fields, $fields);

        return $this;
    }
748998
public function setFields(array $fields)
    {
        $this->fields = $fields;
        $this->queryBuilder->select(implode(', ', $fields));
        return $this;
    }
954177
public function select($fields = [])
    {
        if (is_array($fields)) {
            foreach ($fields as $field) {
                $this->addSelect($field);
            }
        } elseif (is_string($fields)) {
            $this->addSelect($fields);
        }

        return $this;
    }
536148
public function mapFrom($field)
    {
        return isset($this->mapping[$field]) ? $this->mapping[$field] : $field;
    }
42829
protected function parseField(Query $query, $fields)
    {
        if ('*' == $fields || empty($fields)) {
            $fieldsStr = '*';
        } elseif (is_array($fields)) {
            // 支持 'field1'=>'field2' 这样的字段别名定义
            $array = [];

            foreach ($fields as $key => $field) {
                if (!is_numeric($key)) {
                    $array[] = $this->parseKey($query, $key) . ' AS ' . $this->parseKey($query, $field, true);
                } else {
                    $array[] = $this->parseKey($query, $field);
                }
            }

            $fieldsStr = implode(',', $array);
        }

        return $fieldsStr;
    }
1036463
public function fields(array $fields)
    {
        foreach ($fields as $field) {
            if ($field instanceof Mapper) {
                $this->addFieldFromMapper($field);
                continue;
            }
            $this->fields[] = $field;
        }

        return $this;
    }
343631
public function GroupBy($fields): QueryBuilder
    {
        if (is_array($fields)) {
            $fields = implode(', ', $field);
        }
        
        $this->group_by = $fields;
        
        return $this;
    }