1.两个表查询
$userid=session('user.id');
$user = M('cuser');
$data = $user->field('projectno')->where(array('id'=>$userid))->select();
$xq = M('project');
$datas = $xq->field('name')->where(array('id'=>$data[0][projectno]))->select();
$this->assign('xq',$datas);
$this->assign('title',$datas[0][name].'物业系统');
2.联合查询:联合查询需要写表的全名。
$userid=session('user.id');
$user = M('cuser');
$data = $user->join('INNER JOIN pro_project ON pro_cuser.projectno = pro_project.id')->where(array('pro_cuser.id'=>$userid))->select();
$this->assign('xq',$data);
$this->assign('title',$data[0][name].'物业系统');