O'Reilly logo

CakePHP 1.3 Application Development Cookbook by Mariano Iglesias

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding bindings on the fly

This recipe shows how to set up new bindings right before a find operation, including bindings that are automatically removed after the operation is executed, and bindings that are permanently added.

Getting ready

We need some sample models and data to work with. Follow the Getting ready section of the recipe, Modifying binding parameters for a find.

How to do it...

If we want to obtain the latest published Article when we are fetching a User, we could add a permanent binding to the User model. However, if we want to do this on a need-by-need basis, it is smarter to add the binding before the find operation that needs it, thus avoiding the unneeded overhead for other operations.

We can add the needed binding and then issue ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required