bmfs.net
当前位置:首页 >> thinkphp join >>

thinkphp join

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

要,用双下滑下加表名大写方式,例如: $count = D('Document') ->join('__TAG_DOCUMENT__ ON id = document_id') ->where(array('model_id'=>2,'status'=>1,'pid'=>0)) ->count('DISTINCT id');

$wish = $JOKES->join('inner join user on jokes.uid = user.id')->order('time DESC')->limit($limit)->select();

join是表关联,这里的语句翻译成mysql就是这样: select * from think_Artist inner join think_work on think_Artist.id=think_work.artist_id

join是用来联表查询的吧,比如你第一个join()里的内容,表示你联work这个表,连接条件是artist表里的id等于work表里的artist_id,第二个join同理。满意请采纳,不明白请追问。

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

表1.typeid=表2.typeid where(array('表1或表2.userid'=>$where))

可以写两个join $result = $room->join('left join r_hospital on r_department.hospital_id=r_hospital.id ')->join(' doctor on doctor.id = xx.id')->where($condition)->select();

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

这种表达式看起来很怪! 去掉 AND 可以吗?

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