Home >PHP Framework >ThinkPHP >Thinkphp uses join table query method
This article introduces the method of using join table query in Thinkphp. It has certain reference value. I hope it will be helpful to all friends who are learning thinkphp!
Thinkphp uses join table query method
Multiple table join query:
$user = M('user'); $b_user = M('b_user'); $c_user = M('c_user'); $list = $user->alias('user')->where('user.user_type=1') ->join('b_user as b on b.b_userid = user.user_id') ->join('c_user as c on c.c_userid = b.b_userid') ->order('b.user_time') ->select();
$user table The user_id is equal to the b_userid of the $b_user table;
The c_userid of the $c_user table is equal to the b_userid of the $b_user table;
Recommended learning: thinkphp tutorial
The above is the detailed content of Thinkphp uses join table query method. For more information, please follow other related articles on the PHP Chinese website!