I'm trying to get all of the values in a certain field in a table. The basic query:
SELECT `field`
FROM `table`
WHERE `category`="something"
ORDER BY `other_field` DESC
The names of these fields will be return to an AJAX call, so my idea right now is to get this information into an array, and then json_encode that array.
But it's just a list of names, and it's ending up in JavaScript. And my "array/encode" method would require going over the results twice (when the query returns, I'd have to convert a two-dimensional array to one-dimensional). I'd like to avoid that, if possible.
So is there a better method to do this that I don't see? Is there MySQL function that will return all the fields as a single array?