Here’s an example of CakePHP Containable behaviour. Although, it was not a very complex find call but the beauty of the containable is this that you can fetch records using “tricky ways” which normally may not be possible with straight associations find calls.
For example look at the following code at the line 6. I could call the association of model Control which is User model and I could have model name and mixed fields in the same array of argument. Then I could supply the field names of the User model in the same array along with id and control_name which are related to Control model.
$options = array(
‘conditions’ => array(‘ControlsAssignee.’ . $this->Control->primaryKey => $id),
‘Control’=>array(‘User’, ‘User.id’, ‘User.full_name’, ‘id’, ‘control_name’),
Hello Friends, I’m Arvind Kumar, founder of Inimist Technologies, Inimist Academy, The Fundabook and many more. I am a Full Stack Web Developer and Programmer by heart, and a Hindi/English blogger by chance. I build Web and Mobile Application around React, VueJS, NodeJS and PHP frameworks.
Have a project in mind? Get in touch