夺命雷公狗TP下关联查询

记录下我们常用的关联查询:

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

 

posted @ 2016-04-18 19:40  夺命雷公狗  阅读(189)  评论(0编辑  收藏  举报