thinkphp中联表查询(多表)
ps:本人亲测,阿里云2核4G5M的服务器性价比很高,新用户一块多一天,老用户三块多一天,最高可以买三年,感兴趣的可以戳一下:阿里云折扣服务器
//编辑订单
public function order_edit(){
$obj=M('car_order');
$obj1=M('car_project');
if(!empty($_REQUEST['id'])){
$id = I('get.id');
$res = $obj->alias('a')->join('join cms_car_brand as b on a.order_brand=b.id join cms_car_style as c on a.order_style=c.id join cms_car_output as d on a.order_output=d.id join cms_car_year as e on a.order_year=e.id')->where("a.id=$id")->field('a.id as aid,a.order_user_name as ausername,a.order_ment as ament,a.order_weixiu_content as aweixiu,a.order_car_num as anum,a.order_price as aprice,a.order_status as astatus,a.order_type as atype,a.order_licheng as alicheng,b.brand_name as bname,c.style_name as cname,d.output_name as dname,e.year_name as ename,a.order_project as aproject')->find();
$arr=explode('-',$res['aproject']);
foreach($arr as $a){
$pro_id['id']=$a;
$b=$obj1->where($pro_id)->find();
$res1[]=$b['project_name'];
}
$this->assign('res1', $res1);
$this->assign('res', $res);
}
$this->display();
}