I’d like to get all of a mysql table’s col names into an array in php?
Is there a query for this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The best way is to use the INFORMATION_SCHEMA metadata virtual database. Specifically the INFORMATION_SCHEMA.COLUMNS table…
It’s VERY powerful, and can give you TONS of information without need to parse text (Such as column type, whether the column is nullable, max column size, character set, etc)…
Oh, and it’s standard SQL (Whereas
SHOW ...is a MySQL specific extension)…For more information about the difference between
SHOW...and using theINFORMATION_SCHEMAtables, check out the MySQL Documentation onINFORMATION_SCHEMAin general…