First create the database and data table, as shown in the figure below (partial screenshot):
Database:
Data table:
(Related tutorial recommendations: yii framework)
jf_stu:
##js_class: js_school: js_record: Example://表连接,查询出学生、班级、校区、记录表的所有数据 $data=Jf_record::find() ->join('join','jf_stu','jf_record.sid=jf_stu.sid') ->join('join','jf_class','jf_stu.cid=jf_class.cid') ->join('join','jf_school','jf_class.xid=jf_school.xid') ->select('*') ->where(['jf_record.re_id'=>$re_id]) ->asArray() ->one(); echo $data['sname'].'<br>'; echo $data['sex'].'<br>'; echo $data['rtime'].'<br>'; echo $data['cname'].'<br>'; echo $data['school'].'<br>'; die;
Programming Introduction column on the php Chinese website!
The above is the detailed content of How to query data through table connection in yii framework. For more information, please follow other related articles on the PHP Chinese website!