Articles tagged with "associations"
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] unbindAssociation
I needed a quick dynamic way to remove numerous associations I had in recent application. I decided the best to do that was through unbindAssociation(), so I made it.
This code was adapted from expects(), a function developed by Tom O'Reilly & expanded by Mariano Iglesias. As mentioned below I didn't want to maintain lists of models, so I adapted the code to remove associations instead.
[Read more] This code was adapted from expects(), a function developed by Tom O'Reilly & expanded by Mariano Iglesias. As mentioned below I didn't want to maintain lists of models, so I adapted the code to remove associations instead.
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] 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