Home  >  Article  >  Backend Development  >  thinkPHP3表关联查询

thinkPHP3表关联查询

WBOY
WBOYOriginal
2016-06-13 12:35:471031browse

thinkPHP三表关联查询
三个表,r_hospital表    r_department表        r_doctor表
       id              id hospital_id        id depart_id  hospital_id
三个表所属关系如上,
两个表关联:我会了,
$condition['hospital_id'] = $data;
// 把查询条件传入查询方法
$result = $room->join('r_hospital on r_department.hospital_id=r_hospital.id')->where($condition)->select();  
求三个表关联语句?

$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(); 这语句不对,不知道哪有问题

thinkphp join 三表关联
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn