我使用了mysql查询:
SELECT doctor_id FROM `appointments`where doctor_id in (SELECT doctor_id FROM doctor_staffs WHERE staff_id=11)
结果:
doctor_id
2
4
5
但我需要知道如何在CakePHP 3中编写它
答案 0 :(得分:-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]);