删除缓存数据
@param string $field 缓存数据的域,如果不提供,则删除全部
@return boolean
422040
public function clear(string $field = null): bool
    {
        Debug::setCache(static::$type, 'clear', 'FIELD', $field);

        // 如果未提供field参数,则清除全部缓存
        if (!$field) {
            return $this->clearAll();
        }

        // 取域缓存
        $keys = $this->get(self::PREFIX_FIELD . $field);
        if ($keys and $keys !== CacheFactory::NOT_FOUND) {

            // 逐个删除域中的所有项
            foreach ($keys as $key) {
                $this->delete($key);
            }

            // 删除域
            $this->delete('Field_' . $field);
        }

        return true;
    }
37378
public function avg($field) {
        $this->statementContext->setFields("AVG({$field}) AS __AVG__");
        $row = $this->findOne();

        //SQL执行发生错误
        if ($row === false) {
            return false;
        }

        return $row['__AVG__'];
    }
639435
public function getField($field)
    {
        if (isset($this->allFields[$field])) {
            return $this->allFields[$field];
        }

        return null;
    }
843493
public function column($field, $key = '')
    {
        $result = false;
        if (isset($this->options['field'])) {
            unset($this->options['field']);
        }
        if ($key && '*' != $field) {
            $field = $key . ',' . $field;
        }
        $cursor = $this->field($field)->fetchCursor(true)->select();
        $cursor->setTypeMap(['root' => 'array']);
        $resultSet = $cursor->toArray();
        if ($resultSet) {
            $fields = array_keys($resultSet[0]);
            $count  = count($fields);
            $key1   = array_shift($fields);
            $key2   = $fields ? array_shift($fields) : '';
            $key    = $key ?: $key1;
            foreach ($resultSet as $val) {
                $name = $val[$key];
                if ($name instanceof ObjectID) {
                    $name = $name->__toString();
                }
                if (2 == $count) {
                    $result[$name] = $val[$key2];
                } elseif (1 == $count) {
                    $result[$name] = $val[$key1];
                } else {
                    $result[$name] = $val;
                }
            }
        } else {
            $result = [];
        }
        return $result;
    }
522773
protected function isExcluded($field)
    {
        return isset($this->options['field']) && $this->options['field'] !== $this->getKey($field);
    }
558904
public function count($field = '*')
    {
        if (!empty($this->options['group'])) {
            // 支持GROUP
            $options = $this->getOptions();
            $subSql  = $this->options($options)
                ->field('count(' . $field . ') AS think_count')
                ->bind($this->bind)
                ->buildSql();

            $query = $this->newQuery()->table([$subSql => '_group_count_']);

            if (!empty($options['fetch_sql'])) {
                $query->fetchSql(true);
            }

            $count = $query->aggregate('COUNT', '*');
        } else {
            $count = $this->aggregate('COUNT', $field);
        }

        return is_string($count) ? $count : (int) $count;
    }
1199956
public function canMap(Field $field)
    {
        return
            $field->type instanceof FieldType\MultipleStringField ||
            $field->type instanceof FieldType\TextField ||
            $field->type instanceof FieldType\FullTextField;
    }
15614
public function errors($field = null)
    {
        if ($field !== null) {
            return isset($this->_errors[$field]) ? $this->_errors[$field] : false;
        }

        return $this->_errors;
    }
527138
public function validated($field = null, $default = false)
	{
		if ($field === null)
		{
			return $this->validated;
		}

		return array_key_exists($field, $this->validated) ? $this->validated[$field] : $default;
	}
294708
public function fieldPosition($field)
    {
        if (is_string($field)) {
            $field = $this->fieldByName($field);
        }
        if (!$field) {
            return false;
        }

        $i = 0;
        foreach ($this->children as $child) {
            /** @var FormField $child */
            if ($child->getName() == $field->getName()) {
                return $i;
            }
            $i++;
        }

        return false;
    }
1006439
public function max($field) {
        $this->statementContext->setFields("MAX({$field}) AS __MAX__");
        $row = $this->findOne();

        //SQL执行发生错误
        if ($row === false) {
            return false;
        }

        return $row['__MAX__'];
    }
260109
public function inError(string $field): bool
    {
        foreach ($this->_errors as $item) {
            if ($field === $item['name']) {
                return true;
            }
        }
        return false;
    }
1032286
public function fieldExists($field, $table) {
        $fieldLists = $this->query("DESC " . $this->getPrefix() . $table);
        foreach ($fieldLists as $f) {
            if (strtolower($f['Field']) == strtolower($field)) {
                return TRUE;
            }
        }
        return FALSE;
    }
663813
private function getMapKeys(string $field): ?array
    {
        $keys = [];
        foreach ($this->data as $row) {
            if (array_key_exists($field, $row) and !in_array($row[$field], $keys) and !is_null($row[$field])) {
                $keys[] = $this->table->escape($row[$field]);
            }
        }

        // 如果本表关联字段无值,不处理
        if (!count($keys)) {
            return null;
        }

        return $keys;
    }
1315020
public function highlight($field)
    {
        if (isset($this->highlighted[$field])) {
            return $this->highlighted[$field];
        }

        return false;
    }
189617
protected static function filter($field)
    {
        $field = preg_replace('/[\.\/\\:;,?$*!#_-]/', '', $field);
        $field = preg_replace('/\s+/', ' ', trim($field));
        return $field;
    }
969112
public function hasFieldValue($field)
    {
        $newFiles = array_get($this->files, 'new.image', []);

        foreach ($newFiles as $fieldName => $file) {
            if ($fieldName == $field) {
                return true;
            }
        }

        $existingFiles = array_get($this->files, 'image', []);

        foreach ($existingFiles as $fieldName => $files) {
            if ($fieldName == $field) {
                $deleted = 0;
                $fileCount = count($files);
                foreach ($files as $file) {
                    if ($file['delete']) {
                        ++$deleted;
                    }
                }
                if ($fileCount == $deleted) {
                    return false;
                } else {
                    return true;
                }
            }
        }

        return false;
    }