thinkphp Join Connection Query

Source: Internet
Author: User

1  Public functionTest ()2         {3             $User= M (' authlist ');4             $rs=$User-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(' wifi_shop on wifi_authlist.shopid = Wifi_shop.id ')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 ();

thinkphp Join Connection Query

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.