thinkphp关联查询有关问题,join
时间:2021-07-01 10:21:17
帮助过:3人阅读
thinkphp关联查询问题,join
$result = $room->join('r_hospital on r_department.hospital_id=r_hospital.id')->where(array('hospital_id'=>array('exp','is not null')))->select();
大神们看看,where(array('hospital_id'=>array('exp','is not null')))这句话是什么意思?结果显示出来所有的医院,但我只想查某一个,把医院id等于$data,怎么做
thinkphp
关联查询
分享到:
------解决方案--------------------
$condition['hospital_id'] = $data;
// 把查询条件传入查询方法
$result = $room->join('left join r_hospital on r_department.hospital_id=r_hospital.id left join doctor on doctor.id = xx.id')->where($condition)->select();