How would you check in php that a string is a valid compatible column name for a sql statement? just a string match.
If i'd had the same question, I'd search particular database documentation for the certain character list and then implement it in the form of regexp.
But I would never face such a question because basic latin characters, numbers and underscore are more than enough to name any field I use. So I'd keep great portability and maintainability.