如何使用"在查询中的位置" cakephp 3.x

时间:2017-05-22 06:12:52

标签: cakephp

我使用了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中编写它

1 个答案:

答案 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]);