-1

i have use mysql query:

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

Result:

doctor_id
2
4
5

but I need to know how to write it in CakePHP 3

Aman Rawat
  • 2,625
  • 1
  • 25
  • 40

1 Answers1

-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]);
Mazba Kamal
  • 520
  • 2
  • 16