$this->loadmodel('UserinGroup'); $11111= $this->UserinGroup->find('count', array( 'conditions' => array( 'UserinGroup.userid' => $userid, ) )); $arr = array(); foreach ($1111 as $values) { $this->loadModel('Group'); $arr[]= $this->Group->find('all', array( 'conditions' => array( 'Grup.id' => $values['useringorups ']['groupid'], ) )); } $arr2 = array(); foreach ($arr as $values) { $this->loadModel('User'); $arr2[]= $this->User->find('all', array( 'conditions' => array( 'User.id' => $values['Group ']['teamleaderid'], ) )); }