Search code examples
phpcakephpcakephp-bake

Accessing array of variables in CakePHP bake script?


I'm trying to modify the CakePHP bake script so that I can incorporate saving of images from an image helper in an appropriately named field.

How do I go about getting the list of fields/variables in my model? I see that the $modelObj object is available, I've tried performing json_encode on this to get an idea for what's inside and theres a "_schema" list which seems to have all my field names inside... but I can't access this as it's not an array?


Solution

  • Make a call to:

    $this->ModelName->schema()
    

    It will return a field-by-field list containing field names and data types.