I have a mysql table that looks something like this:
id | col_1 | col_2 | col_3
---|-------|-------|------
1 | 2 | 34 | 64
2 | 6 | 53 | 23
>
You could do it like this, this will return to you 2 comma separated first one of columns second of values, which you can explode and merge into KEY/VALUE arrays in PHP.
SELECT
GROUP_CONCAT(COLUMN_NAME) AS _columns,
(SELECT
GROUP_CONCAT(columnName, ',', columnName)
FROM table_name
WHERE id = 1)
FROM
information_schema.columns
WHERE
table_name = 'table_name'
AND COLUMN_NAME IN ('columnName' , 'columnName');