diff --git a/includes/db_handlers/all_functions_include.php b/includes/db_handlers/all_functions_include.php index 37726e910d..9b87053ba9 100644 --- a/includes/db_handlers/all_functions_include.php +++ b/includes/db_handlers/all_functions_include.php @@ -100,6 +100,29 @@ } }); +/** + * Get the column names of a table + * + * @param $table + * + * @return array + */ +function dbkeys($table) { + static $col_names = []; + + if (empty($col_names[$table])) { + $res = dbquery("SHOW COLUMNS FROM $table"); + $col_names = []; + while ($rows = dbarray($res)) { + $col_names[$table][] = $rows['Field']; + } + } + + return (array)$col_names[$table] ? array_map(function ($k) { + return ''; + }, array_flip($col_names[$table])) : []; +} + /** * Send a database query *