@param string $table
@param string $column

@throws MysqlException
@return array

returns the list of enumerated values within a MySQL ENUM column.
throws an exception if the requested column is not of the ENUM (or
SET) type.
516713
public function getEnumValues(string $table, string $column): array {
		$query = <<<QUERY
			SELECT COLUMN_TYPE
			FROM INFORMATION_SCHEMA.COLUMNS
			WHERE TABLE_SCHEMA = :database
			AND TABLE_NAME = :table
			AND COLUMN_NAME = :column
			AND DATA_TYPE IN ('enum','set')
QUERY;
		
		$params = [
			"database" => $this->database,
			"table"    => $table,
			"column"   => $column,
		];
		
		try {
			$type = $this->getVar($query, $params);
		} catch (DatabaseException $databaseException) {
			throw $this->prepareMysqlException($databaseException, $query, $params);
		}
		
		// now we want to (a) confirm that this is an enum (or set) field, and
		// if so (b) extract the set of possible values that it represents.
		// string manipulation to the rescue!
		
		if (strpos($type, "enum(") === 0 || strpos($type, "set(") === 0) {
			
			// the type information is in the form of enum('a','b','c',...,'z').
			// we can match that information with a regular expression as follows.
			
			preg_match_all("/'([^']+)'/", $type, $matches);
			$values = $matches[1];
		} else {
			throw new MysqlException("getEnumValues failed: type mismatch");
		}
		
		return $values;
	}
1308316
public function keyContainsValue($column)
    {
        // must use array_key_exists() because the key could
        // exist but have a NULL value (that'd be valid).
        return (array_key_exists($column, $this->map) && ($this->map[$column]->getValue() !== null));
    }
900887
protected function columns(Table $table)
		{
			$columns = array();

			foreach ($table->columns as $column) {
				// Each of the data type's have their own definition creation method,
				// which is responsible for creating the SQL for the type. This lets
				// us to keep the syntax easy and fluent, while translating the
				// types to the correct types.
				$sql = $this->wrap($column) . ' ' . $this->type($column);

				$elements = array('nullable', 'defaults', 'incrementer');

				foreach ($elements as $element) {
					$sql .= $this->$element($table, $column);
				}

				$columns[] = $sql;
			}

			return $columns;
		}
407775
protected function getFieldByColumn($column)
    {
        return $this->builder->fields()->first(
            function (Field $field) use ($column) {
                if (is_array($field->column())) {
                    return in_array($column, $field->column(), true);
                }

                return $field->column() === $column;
            }
        );
    }
1094258
public function column($column)
    {
        $result = $this->fields($column)->one(); 

        // only return something if something is found
        if (is_array($result))
        {
            return reset($result);
        }
    }
320207
protected function getListSelect($column, $key)
    {
        $select = is_null($key) ? array($column) : array($column, $key);

        if (($dot = strpos($select[0], '.')) !== false) {
            $select[0] = substr($select[0], $dot + 1);
        }

        return $select;
    }
654590
protected function _fetchTableColumns($table)
    {
        $result = array();
        $sql    = $this->quoteName($this->getTableNeedle().$table);

        if ($columns = $this->show('SHOW FULL COLUMNS FROM '.$sql, AnDatabase::FETCH_OBJECT_LIST)) {
            foreach ($columns as $column) {
                //Set the table name in the raw info (MySQL doesn't add this)
                $column->Table = $table;

                //Parse the column raw schema data
                $column = $this->_parseColumnInfo($column, $table);

                $result[$column->name] = $column;
            }
        }

        return $result;
    }
1247362
public function hasColumn($table, $column)
    {
        $column = strtolower($column);

        return in_array($column, array_map('strtolower', $this->getColumnListing($table)));
    }
334756
public function lists($column, $key = null)
    {
        return parent::lists(
            $this->getColumnName($column),
            $key
        );
    }
764377
public function getAutoIncrementValue(string $table, string $column = 'id')
    {
        $query = $this->connection->createQueryBuilder();
        $query->select($this->connection->getDatabasePlatform()->getMaxExpression($column) . ' AS id')
            ->from($table);

        $data = $query->execute()->fetchAll(PDO::FETCH_ASSOC);

        return (int) ($data[0]['id'] ?? 0) + 1;
    }
1313020
protected function getListSelect($column, $key) {
        $select = is_null($key) ? [$column] : [$column, $key];

        // If the selected column contains a "dot", we will remove it so that the list
        // operation can run normally. Specifying the table is not needed, since we
        // really want the names of the columns as it is in this resulting array.
        return array_map(function ($column) {
            $dot = strpos($column, '.');

            return $dot === false ? $column : substr($column, $dot + 1);
        }, $select);
    }
804755
public function hasColumn ($table, $column)
		{
			$schema = $this->db->getTableSchema($table);

			return isset($schema->columns[ $column ]);
		}
1136109
protected function prepareDefaultValue(Column $column)
    {
        $typeMapper = $this->getDataType();

        $default = $column->getDefault();

        if (!$column->getAllowNull() && $default === null && !$column->isPrimary()) {
            $default = $typeMapper::getDefaultValue($column->getType());

            $column->defaultValue($default);
        }

        return $column;
    }
894996
final public function field($column)
    {
        $key = $column;
        if (strpos($column, '.') !== false) {
            list(, $key) = explode('.', $column);
        }
        $key = str_replace('`', '', $key);
        $this->select($column);
        $info = $this->get();
        if (!isset($info[$key])) {
            throw  new Exception('参数错误，您的参数只能为 field 或者 table.field的形式', Exception::CODE_PARAM_VALUE_ERROR);
        }
        return $info[$key];
    }
83931
public function getColumns($table)
    {
        //Argument 1 must be a string
        Argument::i()->test(1, 'string');
        
        $query = $this->utility()->showColumns($table);
        $results = $this->query($query, $this->getBinds());
        
        $columns = array();
        foreach ($results as $column) {
            $key = null;
            if ($column['pk'] == 1) {
                $key = 'PRI';
            }
            
            $columns[] = array(
                'Field'     => $column['name'],
                'Type'      => $column['type'],
                'Default'   => $column['dflt_value'],
                'Null'      => $column['notnull'] != 1,
                'Key'       => $key);
        }
        
        return $columns;
    }
106133
public function getColumnLabel($column, $table)
    {
        /** @var \yii\db\ActiveRecord $model */
        $model = $this->_currentModel;
        /** @var Module $module */
        $module = $this->module;
        if (isset($model->attributeLabels()[$column])) {
            return $model->attributeLabels()[$column];
        } elseif ($module->tables[$table]['relations'][$column]['label']) {
            return $module->tables[$table]['relations'][$column]['label'];
        } else {
            return $column;
        }
    }
333680
public function getEnumValues($tableName, $columnName) {

		// check whether column exists

		if(!$this->columnExists($tableName, $columnName)) {
			throw new \PDOException(sprintf("Unknown column '%s' in table '%s'.", $columnName, $tableName));
		}
		
		// wrong data type
		
		$dataType = $this->tableStructureCache[$tableName][$columnName]['dataType']; 
		
		if(!($dataType === 'enum' || $dataType === 'set')) {
			throw new \PDOException(sprintf("Column '%s' in table '%s' is not of type ENUM or SET.", $columnName, $tableName));
		}
		
		// extract enum values the first time

		if(!isset($this->tableStructureCache[$tableName][$columnName]['enumValues'])) {
			preg_match_all(
				"~'(.*?)'~i",
				$this->tableStructureCache[$tableName][$columnName]['columnType'],
				$matches
			);
			
			$this->tableStructureCache[$tableName][$columnName]['enumValues'] = $matches[1];
		}
		
		return $this->tableStructureCache[$tableName][$columnName]['enumValues'];
		
	}