首頁  >  文章  >  後端開發  >  ThinkPhp多表查询的有关问题,求帮助

ThinkPhp多表查询的有关问题,求帮助

WBOY
WBOY原創
2016-06-13 13:52:54872瀏覽

ThinkPhp多表查询的问题,求帮助

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
public function graduate(){
        $this->checkLogin();//判断登录
        $Graduate=M('Graduate');
        $category=$_GET['category'];
        $map['FLG']='0';
        $map['LAN']='01';
        import("@.ORG.Page");
        $count = $Graduate->join('LEFT OUTER JOIN PERSON ON(GRADUATE.PERSONID=PERSON.PERSONID andPERSON.FLG='.$FLG.')')->where($map)->count();
        $p = new Page ($count, 10 );
        $list=$Graduate->limit($p->firstRow.','.$p->listRows)->join('LEFT OUTER JOIN PERSON ON GRADUATE.PERSONID=PERSON.PERSONID and PERSON.FLG=0')->where($map)->order('GRADUATE.GRADUATEID DESC')->findAll();
        $page = $p->show ();
        $pagenumber=$p->nowPage;
        $this->assign ("pagenumber", $pagenumber-1 );
        $this->assign ("page", $page );
        $this->assign ("list", $list );
        $this->display();
    }



Graduate表的personID是Person表的外键,join后查不到值,哪个大侠帮看看什么问题?
还有,这东西分大小写么?
ps:不会php,但是boss让买个bug。。。

------解决方案--------------------
$list=$Graduate->limit($p->firstRow.','.$p->listRows)->join('LEFT OUTER JOIN PERSON ON GRADUATE.PERSONID=PERSON.PERSONID and PERSON.FLG=0')->where($map)->order('GRADUATE.GRADUATEID DESC')->findAll();
后面:
echo $Graduate->getLastSql();
看下最后sql执行语句是什么,是否sql有错误
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn