Reputation: 11693
How would I fetch the name of all the fields in a table of a database using PHP Data Objects?
Upvotes: 0
Views: 77
Reputation: 282
to do this you have to query the db schema. In MySQL, there is a system generated database called information_schema.
from within it, you could run:
SELECT column_name
FROM COLUMNS
WHERE table_name = 'desired_table'
AND table_schema = 'database_name'
Upvotes: 3