FiftyOneReasons

Interactive Media Development + Exploration

Dynamic Model Binding in CakePHP

One topic in CakePHP that took some time to wrap our heads around was binding to a model dynamically – that is, if you’re working in a Controller and would like to access another Model without registering the Model in the $uses array (exposing the model to the entire Controller). On occasion, this can be a handy snippet – for example in a switch statement where you’re segregating calls to different Models based on a certain criteria. continued…