2017-05-22 2 views
-1

i Verwendung mysql query haben:wie "wo in Abfrage" cakephp 3.x verwenden

SELECT doctor_id FROM `appointments`where doctor_id in (SELECT doctor_id FROM doctor_staffs WHERE staff_id=11) 

Ergebnis:

doctor_id 
2 
4 
5 

aber ich muss wissen, wie es zu schreiben in CakePHP 3

+0

Mögliches Duplikat von [Unterabfragen in CakePHP 3?] (http: // stackov erflow.com/questions/33884603/subqueries-in-cakephp-3) – drmonkeyninja

Antwort

-1
$this->loadModel('DoctorStaffs'); 
    $docTorStaff=$this->DoctorStaffs->find()->select(['doctor_id'])->where(['staff_id'=>11]); 
    $this->loadModel('Appointments'); 
    $appointments = $this->Appointments->find(); 
    $appointments=$appointments->where(['Appointments.doctor_id IN'=>$docTorStaff]);