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();

以一个 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...

给你一个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();

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

$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)

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...

$data = M()->table('user as a')->join('jifen as b on b.id = a.id')->where(' a.id = 1 ')->select();

M('item')->join('repayment ON item.关联字段 =repayment.关联字段')->where('表名.user_uid = '.$value['id'])->getfield('字段')

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