This recipe shows how to use
Containable to change the conditions used to fetch data related to a model through a binding.
We need to have
Containable added to our models, and we also need some sample models and data to work with. Follow the recipe, Adding Containable to all models, and the Getting ready section of the recipe, Modifying binding parameters for a find.
If we want to obtain the first
User record together with the published
Article records that user owns, but ordered by latest articles first, and limiting some of the returned fields, we use the
conditions binding setting:
$user = $this->User->find('first', array( 'contain' => array( 'Article' => array( 'fields' => array('Article.title'), ...