Home > PHP Framework > YII > body text

How to query data through table connection in yii framework

王林
Release: 2020-02-19 11:44:58
Original
2115 people have browsed it

How to query data through table connection in yii framework

First create the database and data table, as shown in the figure below (partial screenshot):

Database:

How to query data through table connection in yii framework

Data table:

(Related tutorial recommendations: yii framework)

jf_stu:

How to query data through table connection in yii framework

##js_class:

How to query data through table connection in yii framework

js_school:

How to query data through table connection in yii framework

js_record:

How to query data through table connection in yii framework

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[&#39;sname&#39;].&#39;<br>&#39;;
		echo $data[&#39;sex&#39;].&#39;<br>&#39;;
		echo $data[&#39;rtime&#39;].&#39;<br>&#39;;
		echo $data[&#39;cname&#39;].&#39;<br>&#39;;
		echo $data[&#39;school&#39;].&#39;<br>&#39;;
		die;
Copy after login

Output result:


How to query data through table connection in yii framework

For more programming-related content, please pay attention to the

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!