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

thinkphp join

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

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

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

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

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

可以写两个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();

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

$m = M(b);$m->join('a on a.id = b.id') ->join('c on c.id = b.id') ->select();

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

$Model->table('__COMMENT__ a') ->join('__USER__ b on a.uid=b.id') ->field('a.id,a.content,a.create,a.uid,b.username,b.domain') ->where('a.tid='.$tid) ->order('a.create DESC') ->count();

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