Custom method, related to model
Can you help me how to develop custom methods in CakePHP framework.
I found this code in stac开发者_Go百科koverflow, but it's global, it's not "model related".
Can you help me with this?
Thank you in advance!
If the code is related to the retrieval or 'serving' of data, put it in the appropriate model.
If you are writing code that is going to do something with or without that data, ultimately for display on a webpage, put it in the controller.
If you're manipulating data for display - e.g. looping over an array of results to build a table (see a standard CakePHP index.ctp for an example) or if you're simply echoing data to display or using helpers to build a page, then it goes in the view (.ctp).
This is all well covered in the first three chapters of the book.
精彩评论