Contain my excitement!
Article posted by Joel Moss on 25 Jun 2007   |  
Last month I read - more like scanned - over a post on Felix Geisendörfer's (the_undefined) blog all about a new behaviour he had just written for CakePHP. At the time I didn't really get it and so didn't see its value. But today while progressing with my Cake rewrite of Switchboard, I had a need to limit the associations that Cake was returning. The most obvious way was to play with the $recursive variable in my models, but that just isn't fine grained enough. So I hopped on over to the Cake IRC channel and asked how others were doing it. Luckily for me, Felix had also hopped on over and suggested I take a look at his containable behaviour. He had just released version 2.0, so I grabbed the code and started playing. Why the hell didn't I ever use this before? It has solved all my association problems and is so damn easy to use. Just stop what you are doing right now and get his code and add the behaviour to your cake apps. I promise you that you will never look back. Core team, if you are reading this then you have to put this in the core.

This site contains the musings of Joel Moss, and is powered by Codaset pages; a simple, yet powerful way to host your static site. Just commit and push your site to your free Git repository at Codaset, and that's it!