您的位置:首页 > 编程语言 > PHP开发

夺命雷公狗TP下关联查询

2016-04-18 19:40 639 查看
记录下我们常用的关联查询:

public function add4(){
$id=$_GET['id'];
$this->list = M("student")->table("hx_student stu,hx_subject sub")
->where("stu.id=$id and stu.bmcx=sub.motorcycletype")
->field('stu.name,sub.examination,sub.name subname,sub.id subid')->select();
$this->display('add4');
}

$total = $model->
table('hx_test t, hx_student s, hx_subject b')->
where('s.id=t.studentid and b.id=t.subjectid')->
count();//获取总数据条数

$lists = $mod ->field('s.name sname,t.name tname,a.oddnumbers,a.evaluate,a.grade,a.time,a.id')->
table("hx_appraise a,hx_student s,hx_train t")->
where("s.id=a.studentid and t.id=a.trainerid")->
limit($page->firstRow.','.$page->listRows)->order('id DESC')->select();
$this ->assign('lists',$lists);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: