PHP

Convert MySQL column names to PHP array

function getTableColumnNames($table) {
    if ($table) {
        $query = "SHOW COLUMNS FROM " . $table;
        $res = $GLOBALS['TYPO3_DB']->sql_query($query);
        $fields = array();
        while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
            $fields[] = $row['Field'];
        }
        return $fields;
    }
}