CakePHP has a very easy way to handle bindings, and through the use of the Containable
behavior, as shown in several recipes in Chapter 2, Model Bindings, we have a lot of flexibility when dealing with bindings.
However, there are times where we need to fall outside of a normal find operation and perform queries that join several models, without using normal binding operations, to save us some valuable queries. In this recipe, we will see how to specify JOIN
operations when performing a find on a model.
We need some sample models and data to work with. Follow the Getting ready section of the recipe, Performing GROUP and COUNT queries.
To illustrate the difference between normal binding operations and what is shown in this recipe, we need the Containable
behavior. Create a file named app_model.php
and place it in your app/
folder, with the following contents. If you already have one, make sure that, either you add the actsAs
property shown as...