rchg.net
当前位置:首页 >> thinkphp多表联合查询 >>

thinkphp多表联合查询

以一个 user 表和 jifen 表联查为例,, 第一种方式: $data = M('user as a')->join('jifen as b on b.id = a.id')->where('a.id = 1')->select(); 第二种: $data = M()->table('user as a')->join('jifen as b on b.id = a.id')->where(' a.id...

$Model = M('T1'); $Model->join('t2 on t1.id = t2.uid', 'left')->join('t3 on t2.uid = t3.sid', 'left')->select();

$Model = M('Artist'); $map['name'] = array('like','thinkphp%'); $Model ->join('think_work ON think_artist.id = think_work.artist_id') ->join('think_card ON think_artist.card_id = think_card.id') ->where($map) ->select();

M("User u")->join("sex s,deparment d,job j")->where("u.sex=s.id,u.department=d.id,u.job=j.id")->select(); ps:下次弄个可以粘贴的,不然线下没法测试。

给你一个tinkphp的join实例: $Model = M('Artist'); $Model->join('think_work ON think_artist.id = think_work.artist_id')->join('think_card ON think_artist.card_id = think_card.id')->select();

$aa=$D('ab')->join(B ON A.day=B.day)->where($dada)->select();

$data['id'] = array('IN',array(3,6,7,12,34)); $news=$new->where($data)->select(); 相当于 select * from wujiang where id in(3,6,7,12,34)

M('user')->field('u.*')->join('u left join new n on n.userid = u.userid')->select();echo M('user')->getLastSql();// 查看上一条sql语句

$ObjTbvcbgroupmap = M('B');//M一个中间桥梁方法 $arrData = $ObjTbvcbgroupmap ->field('*') ->join('A ON A.ngroupid = B.ngroupid')/*关联表*/ ->join('C ON C.nvcbid = B.nvcbid') /*关联表*/ ->select(); echo ''; print_r($arrData);//这...

array(2) { [0] => array(4) { ["Hotel_Id"] => string(1) "4" ["Hotel_Name"] => string(24) "重庆南方君临酒店" ["Hotel_Stars"] => string(1) "1" ["hotelroomlist"] => array(3) { [0] => array(3) { ["Room_id"] => string(1) "1" ["Room_N...

网站首页 | 网站地图
All rights reserved Powered by www.rchg.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com