October 18, 2006

CakePHP needs getters and setters in it's model...

I've spent far to much time trying to create an afterFind() method to change my date fields from yyyy-mm-dd to mm-dd-yyyy. From what I've been able to find, CakePHP doesn't have getters and setters for each field in a model. PEAR::DB_DataObject uses these to easily modify or format fields whenever they are retrieved or saved.


In DB_DataObject, I'd simply change getBirthday() (for the birthday field) to change the format to mm-dd-yyyy, but in CakePHP, I get to write a giant afterFind() method that can process all potential returns from a find request--these come in various forms of hierarchical arrays, single dimension arrays, or even strings. Most of the code I've written to make this work has been simply to handle every possible return from a find() request.


In the end it's just making Django look more and more enticing. :)

Posted by TheIdeaMan at October 18, 2006 10:00 AM | TrackBack
Comments
Post a comment









Remember personal info?