How to get the field names of the table in CakePHP

Asim Zaidi picture Asim Zaidi · Apr 30, 2011 · Viewed 11.9k times · Source

I am a complete newbie in CakePHP. I want to read the field names of the table in the controller.

I want the controller to list all the field names in the table. How do I do that?

Answer

dhofstet picture dhofstet · Apr 30, 2011

Use the following snippet to get an array of the field names (replace "YourModel" with the name of your model):

array_keys($this->YourModel->getColumnTypes());