thinkphp Join connection query, Thinkphpjoin
1 Public functionTest ()2 {3 $User= M (' authlist ');4 $rs=$User-Join(' Left join wifi_shop on wifi_authlist.shopid = Wifi_shop.id ')->field ('5 Wifi_authlist.id,6 Wifi_authlist.shopid,7 Wifi_authlist.routeid,8 Wifi_authlist.mac,9 Wifi_authlist.over_time,Ten Wifi_shop.id, One Wifi_shop.shopname, A Wifi_shop.pid, - Wifi_shop.trade, - Wifi_shop.province, the wifi_shop.city, - Wifi_shop.area, - count (Wifi_authlist.mac) as Times -')->where (' Wifi_shop.pid =%s ', 3)->group (' Wifi_authlist.mac ')->order (' Over_time ')->limit ($Page- FirstRow. ', '. $Page->listrows)->select (); +Dump$rs); -}
I am here to check the Wifi_shop and Wifi_authlist table, the connection condition is
Wifi_authlist.shopid = Wifi_shop.id
It is generally important to note that the data table contains a prefix, so the join should be prefixed
Three table joins, plus one join.
1 $rs=$User-Join(' Left join wifi_shop on wifi_authlist.shopid = Wifi_shop.id ')Join(' Left join wifi_phonelist on wifi_authlist.mac = Wifi_phonelist.mac ')->field ('2 Wifi_authlist.id,3 Wifi_authlist.shopid,4 Wifi_authlist.routeid,5 Wifi_authlist.mac,6 Wifi_authlist.over_time,7 Wifi_authlist.agent,8 Wifi_shop.id,9 Wifi_shop.shopname,Ten Wifi_shop.pid, One Wifi_shop.trade, A Wifi_shop.province, - wifi_shop.city, - Wifi_shop.area, the Wifi_phonelist.mac, - Wifi_phonelist.phone, - count (Wifi_authlist.mac) as Times -')->where (' Wifi_shop.pid =%s ',$pid)->group (' Wifi_authlist.mac ')->order (' Over_time ')->limit ($Page->firstrow. ', '.$Page->listrows)->select ();
http://www.bkjia.com/PHPjc/1102858.html www.bkjia.com true http://www.bkjia.com/PHPjc/1102858.html techarticle thinkphp Join connection query, Thinkphpjoin 1 public Function test () 2 {3 $User = M (' authlist ') and 4 $rs = $User-join (' left J Oin wifi_shop on wifi_authlist.shopid = wifi_shop.id ...