How to check if column exists in MySQL table

The following function checks if a column exists in a table.

Doing so by querying SHOW COLUMNS and check how many rows were returned. If none, the column does not exist and it will return false. If found it will return true.