Reputation: 28344
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?
Upvotes: 17
Views: 13476
Reputation: 2463
For CakePHP 3.x
$this->Model->schema() - Returns the Schema object.
$this->Model->schema()->columns() - Returns all of the columns in the table in an array.
Upvotes: 6
Reputation: 9964
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());
Upvotes: 26