Articles tagged with "model"
Keeping bindModel and unbindModel out of your Controllers
Sometimes you need to fine-tune your associations: binding to other Models only when needed or unbinding exisiting relations to minimize the size of your result set. With a very simple method and a slight change in how you write some associations, this can be done cleanly and efficiently right from your controller.
[Read more] An improvement to unbindModel on model side
Not long ago I saw Tom OReilly's great tutorial entitled "Keeping bindModel and unbindModel out of your Controllers." While he showed us some great tips I was not so comfortable having to define my model relations in a different way, but I still wanted the possibility to only specify what relations I want to get when querying a model.
[Read more] cURL Model
This is a wrapper for cURL. Ideal if you need to grab data from another site or integrate into a system that uses GET or POST requests.
[Read more] Testing Models with CakePHP 1.2 test suite
CakePHP test suite is a powerful environment that lets you test small to large applications testing for isolated portions of your code. It is one of the coolest additions to the 1.2 release and in this article we'll see how to use it to test our application models.
[Read more] HABTM Add & Delete Behavior
Many people gripe about the HABTM associations in CakePHP and how difficult it is to add or delete a single record. This behavior takes care of the task for you!
[Read more] SimpleResults Behavior - Re-index results from findAll()
When returning rows from a Model::findAll() call, the result array is indexed in a certain way. This behavior allows models to return their results indexed in the same way as hasMany associations, which is more concise and (in certain circumstances) easier to parse / pass to other functions.
[Read more] Obvious trick to reduce amount of HABTM relationship tables
Trick howto reduce amount of HABTM tables in complex application
[Read more] Model loader
This component helps you to load your models on the fly ( I mean in your actions, whenever).
[Read more] Acts As Emailable
This little behavior is more of a learning experiment for me into how behaviors work in the CakePHP side of things. It helps me with maintaining a list of users who are emailable rather than write a component or a model. Read on for more...
[Read more] ACL Behavior
This behavior is built off of the core Acl behavior. It fixes some issues with the core behavior and allows you to set a model as both an Aro and Aco. It also adds the alias where as the core behavior doesn't.
[Read more] Filter Out Unnecessary Recursive Relationships
Add a small function to your AppModel to filter out those recursive relationships that are unnecessary for a particular controller action.
[Read more]
Latest Comments