Adds GROUP BY to the current query.

@param string|Raw|\Closure|array $field

@return static
519575
public function groupBy($field): IQueryBuilderHandler
    {
        if (($field instanceof Raw) === false) {
            $field = $this->addTablePrefix($field);
        }

        if (\is_array($field) === true) {
            $this->statements['groupBys'] = array_merge($this->statements['groupBys'], $field);
        } else {
            $this->statements['groupBys'][] = $field;
        }

        return $this;
    }
1205089
public function rules($field, array $rules)
    {
        foreach ($rules as $rule)
        {
            $this->rule($field, $rule[0], Arr::get($rule, 1));
        }

        return $this;
    }
1304277
public function removeField($field)
    {
        $field = $this->resolveAlias($field);

        unset($this->fields[$field], $this->data[$field]);

        return $this;
    }
1122348
public function addField($field)
    {
        if ($field instanceof AttachmentField) {
            $this->fields[] = $field;

            return $this;
        } elseif (is_array($field)) {
            $this->fields[] = new AttachmentField($field);

            return $this;
        }

        throw new InvalidArgumentException('The attachment field must be an instance of Maknz\Slack\AttachmentField or a keyed array');
    }
1150597
protected static function query($fields)
    {
        $result = Query::from(static::$table);

        $result = $result->where();

        foreach ($fields as $key => $value) {
            $result = $result->andWhere($key, '=', $value);
        }

        return $result->get();
    }
287187
public function readdField($field)
    {
        $this->checkValidLoader();

        foreach ($this->loaders as $loader => $fields) {
            if (in_array($field, $this->loaders[ $loader ])) {
                array_splice($this->loaders[ $loader ], array_search($field, $this->loaders[ $loader ]), 1);
            }
        }

        $this->addField($field);

        return $this;
    }
723712
public function groupBy($query = [])
    {
        if (!empty($query)) {
            $i = 0;
            $groupBy = $this->getOrderBy();

            foreach ($query as $value) {
                if ($i>0) {
                    $groupBy .= ', ' . $this->table() . '.' . $value;
                } else {
                    $groupBy .= ' GROUP BY ' . $this->table() . '.' . $value;
                }

                $i++;
            }

            $this->setGroupBy($groupBy);
        }

        return $this;
    }
968148
public function order($field) {
        $order = [];
        if (is_array($field)) {
            foreach ($field as $key => $value) {
                $order[] = $key . ' ' . $value;
            }
        } else {
            $order = func_get_args();
        }
        $order = implode(',', $order);
        $this->order = !empty($order) ? ' ORDER BY ' . $order : '';
        return $this;
    }
211801
public function removeField($field)
    {
        foreach ($this->fieldsets as $fieldset) {
            if ($fieldset->hasField($field)) {
                unset($fieldset[$field]);
            }
        }
        return $this;
    }
426738
public static function factory (array $field) 
    {
        foreach (array('tag', 'occurrence', 'subfields') as $index) {
            if (!array_key_exists($index, $field)) {
                throw new InvalidArgumentException("Missing '{$index}' index in field array");
            }
        }
        return new Field($field['tag'],
                         $field['occurrence'],
                         array_map(array('HAB\Pica\Record\Subfield', 'factory'), $field['subfields']));
    }
419066
public function count($field = '*')
    {
        $field = $this->distinct ? "DISTINCT {$field}" : $field;
        return intval($this->select(new Raw("COUNT({$field}) as `aggregation`"))->first(1)->aggregation);
    }
11480
public function whereIn($field, $values)
    {
        foreach ($this->queries as $query) {
            $query->whereIn($field, $values);
        }

        return $this;
    }
145658
public function whereInAll($field = '', $in = array())
		{
			$this->_whereInit($field);
			$this->wheres[$field]['$all'] = $in;

			return $this;
		}
471661
public static function where($field)
    {
        $root = new Node(Node::TYPE_CROTCH, Node::OPERATOR_BLANK);
        $criteria = new Criteria($field, $root);
        $root->append(Node::OPERATOR_BLANK, $criteria);

        return $criteria;
    }
1033092
public function count($field = '*')
    {
        if (isset($this->options['group'])) {
            // 支持GROUP
            $options = $this->getOptions();
            $subSql  = $this->options($options)->field('count(' . $field . ')')->bind($this->bind)->buildSql();
            return $this->table([$subSql => '_group_count_'])->value('COUNT(*) AS tp_count', 0, true);
        }

        return $this->value('COUNT(' . $field . ') AS tp_count', 0, true);
    }
504545
public function keyResultsBy($field)
    {
        $results = clone $this->results;
        $this->results = new Collection;
        foreach ($results as $r) {
            $this->addRecord($r, $field);
        }
    }
751954
public function whereInset($field, $value)
    {
        foreach ($this->queries as $query) {
            $query->whereInset($field, $value);
        }

        return $this;
    }