anda mungkin harus menggunakan subquery():
$subqueryOptions = array('fields' => array('competence_id'), 'conditions' => array('employee_id'=>$user_id));
$subquery = $this->Competence->CompetenceRating->subquery('all', $subqueryOptions);
$res = $this->Competence->CompetenceRating->find('all', array(
'conditions' => array('id NOT IN '. $subquery)
));
sumber untuk subquery ada di sini:https://github. com/dereuromark/tools/blob/2.0/Lib/MyModel.php#L405 Anda harus meletakkan ini di AppModel.php
TAPI saya pikir subquery tidak perlu. Anda mungkin dapat membuat kueri tunggal dan mudah darinya:
$this->Competence->CompetenceRating->find('all', array(
'group' => 'competence_id',
'conditions' => array('NOT' => 'employee_id'=>$user_id)),
'contain' => array('Competence')
));
jangan lupa sertakan Kompetensi melalui "contain" jika Anda telah mengatur rekursif ke -1.