0

I want to know if a specific column exists in a mysql table or not. I have searched for a solution in older posts, but without any luck:

  1. Check if column exist in Mysql table via php
  2. How can I check if mysql table column even exists?
  3. MySQL, Check if a column exists in a table with SQL
  4. Check if column exists, if not, add in MySQL through PHP

What I want to know is whether or not there is any method available in the MySQLi class of PHP to do so?

The reason for asking is that my current project is based on the MySQLi class in PHP.

I have tried the old way of getting work done through querying database of 'information_schema' but for some reason, it was not fruitful. Also, I am preferring PHP built-in methods of the MySQLi class to perform all my tasks.

Community
  • 1
  • 1
Ahmed Naveed
  • 104
  • 1
  • 11

1 Answers1

0

There's a MySQL query to get the column information:

show columns from `table`;

Some more documentation on it here: https://dev.mysql.com/doc/refman/5.7/en/show-columns.html

Andrius
  • 5,934
  • 20
  • 28