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?
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());
as simple as $this->Model->schema()
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With