return all possible options of an enum or set attribute

@param string $tableName
@param string $columnName
@return array

@throws \PDOException
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'];
		
	}
1226899
private function getTableColumns (string $tableName)
    {
        $columns = DB::getSchemaBuilder ()->getColumnListing ($tableName);

        if (!count ($columns))
            $this->abort ("Table not found: " . $tableName);
        else
            $columns = DB::select (DB::raw ('SHOW COLUMNS FROM ' . $tableName));


        return $columns;
    }
973299
public function getTableColumns($tableName)
    {
        $db = $this->getDb();

        $allColumns = $db->fetchAll("SHOW COLUMNS FROM " . $tableName);

        $fields = array();
        foreach ($allColumns as $column) {
            $fields[trim($column['Field'])] = $column;
        }

        return $fields;
    }
1151857
public static function renameColumns($tableName, array $columnNames)
    {
        return [
            'up' => function (Builder $schema) use ($tableName, $columnNames) {
                $schema->table($tableName, function (Blueprint $table) use ($columnNames) {
                    foreach ($columnNames as $from => $to) {
                        $table->renameColumn($from, $to);
                    }
                });
            },
            'down' => function (Builder $schema) use ($tableName, $columnNames) {
                $schema->table($tableName, function (Blueprint $table) use ($columnNames) {
                    foreach ($columnNames as $to => $from) {
                        $table->renameColumn($from, $to);
                    }
                });
            }
        ];
    }
690727
public function getColumnNames($tableName)
    {
        $colNames = array();
        foreach ($this->tableColumnTypes[$tableName] as $colName => $colType) {
            if ($colType['is_virtual']) {
                $this->dumpSettings['complete-insert'] = true;
                continue;
            } else {
                $colNames[] = "`${colName}`";
            }
        }
        return $colNames;
    }
235635
public function column(string $columnName): ColumnTypeDefiner
    {
        return new ColumnTypeDefiner(
            $this,
            function (Column $column) {
                $this->addColumn($column);
            },
            $columnName
        );
    }
295023
public function getOperationValue($fieldName)
    {
        $sql = sprintf(
            '%s %s %s',
            $fieldName,
            $this->strFilterToDbNotation(),
            $this->columnToCompare
        );

        return [
            $sql,
            [],
        ];
    }
335456
public function getColumnType($tableName, $columnName) {
        $columns = $this->getTableColumns($tableName);
        foreach ($columns as $column) {
            if ($column['Field'] != $columnName)
                continue;
            $type = explode('(', $column['Type'], 2);
            return $type[0];
        }
        throw new \Exception("Column `$columnName` not found in table `$tableName`!");
    }
474123
public function listTableForeignKeys(string $tableName) : array
    {
        $tableName = $this->tableMaybeInvalid($tableName);
        return $this->getSchemaManager()->listTableForeignKeys($tableName);
    }
831162
protected function get_select_search_in_column($columnname) {
        global $DB;

        if ($DB->sql_regex_supported()) {
            // Database supports regex, use it for better match.
            $select = $columnname . ' ' . $DB->sql_regex() . ' ?';
            $params = ["(src|data)\ *=\ *[\\\"\']http://"];
        } else {
            // Databases without regex support should use case-insensitive LIKE.
            // This will have false positive matches and more results than we need, we'll have to filter them in php.
            $select = $DB->sql_like($columnname, '?', false);
            $params = ['%=%http://%'];
        }

        return [$select, $params];
    }
1354643
private function convertColumnAnnotationToFieldMetadata(string $tableName, Column $column, string $fieldName)
    {
        $options       = [];
        $fieldMetadata = new Mapping\FieldMetadata($fieldName);

        $fieldMetadata->setType($column->getType());
        $fieldMetadata->setTableName($tableName);
        $fieldMetadata->setColumnName($column->getName());

        // Type specific elements
        switch ($column->getType()->getName()) {
            case Type::TARRAY:
            case Type::BLOB:
            case Type::GUID:
            case Type::JSON_ARRAY:
            case Type::OBJECT:
            case Type::SIMPLE_ARRAY:
            case Type::STRING:
            case Type::TEXT:
                if ($column->getLength()) {
                    $fieldMetadata->setLength($column->getLength());
                }

                $options['fixed'] = $column->getFixed();
                break;

            case Type::DECIMAL:
            case Type::FLOAT:
                $fieldMetadata->setScale($column->getScale());
                $fieldMetadata->setPrecision($column->getPrecision());
                break;

            case Type::INTEGER:
            case Type::BIGINT:
            case Type::SMALLINT:
                $options['unsigned'] = $column->getUnsigned();
                break;
        }

        // Comment
        $comment = $column->getComment();
        if ($comment !== null) {
            $options['comment'] = $comment;
        }

        // Default
        $default = $column->getDefault();
        if ($default !== null) {
            $options['default'] = $default;
        }

        $fieldMetadata->setOptions($options);

        return $fieldMetadata;
    }
1058010
public function getColumnByName(string $columnName) : BufferedSQLResultColumn {
		if (\array_key_exists($columnName, $this->columns)) {
			return $this->columns[$columnName];
		} else {
			throw new \OutOfBoundsException('Column ' . $columnName . ' does not exist in SQL result');
		}
	}
798708
public function getTableColumns($tableName): array
    {
        $schema  = $this->getSchema();
        $columns = $schema->listTableColumns($tableName);

        return $columns;
    }
1298009
public function getTableColumns($tableName) {
        if (!$this->tableColumns){
            if (App::get()->cacheExists('mpf:PDOConnection:tableColumns')){
                $this->tableColumns = App::get()->cacheValue('mpf:PDOConnection:tableColumns');
            }
        }
        if (!isset($this->tableColumns[$tableName])) {
            $this->tableColumns[$tableName] = $this->queryAssoc("SHOW COLUMNS FROM `$tableName`");
            App::get()->cacheSet('mpf:PDOConnection:tableColumns', $this->tableColumns);
        }
        return $this->tableColumns[$tableName];
    }
397795
public function getFields($tableName) {
        list($tableName) = explode(' ', $tableName);
        $result =   $this->query("SELECT   column_name,   data_type,   column_default,   is_nullable
        FROM    information_schema.tables AS t
        JOIN    information_schema.columns AS c
        ON  t.table_catalog = c.table_catalog
        AND t.table_schema  = c.table_schema
        AND t.table_name    = c.table_name
        WHERE   t.table_name = '$tableName'");
        $info   =   array();
        if($result) {
            foreach ($result as $key => $val) {
                $info[$val['column_name']] = array(
                    'name'    => $val['column_name'],
                    'type'    => $val['data_type'],
                    'notnull' => (bool) ($val['is_nullable'] === ''), // not null is empty, null is yes
                    'default' => $val['column_default'],
                    'primary' => false,
                    'autoinc' => false,
                );
            }
        }
        return $info;
    }
243731
public static function getEnumValues($modelName, $enumFieldName)
    {
        $schema = SolutionSchema::getModelSchema($modelName);
        $enum = $schema->getColumns()[$enumFieldName];
        return $enum->enumValues;
    }
364589
public function getIndexes($tableName)
    {
        $sql = sprintf('SHOW INDEX FROM %s', $this->ident($tableName));
        $rows = $this->pdo->query($sql)->fetchAll();
        $result = [];
        foreach ($rows as $row) {
            if (isset($row['Cardinality'])) {
                unset($row['Cardinality']);
            }
            $name = $row['Key_name'];
            $seq = $row['Seq_in_index'];
            $result[$name][$seq] = $row;
        }

        return $result;
    }