thinkphp3.2unionall
$where['enterprise_id'] = $enterpriseId; //企业名称不为空 if(!empty($enterpriseName)){ $where['enterprise_name'] = array('like',"%$enterpriseName%"); } $table2 = array('enterprise_data.yunkh_enterprise_rel_enterprise'=>'ed_ere', 'enterprise_data.yunkh_enterprise_info'=>'ed_ei'); $where2 = array('ed_ere.enterprise_id'=>$enterpriseId, 'status'=>'1', 'ed_ei.enterprise_name'=>array('like',"%$enterpriseName%"), '_string'=>'ed_ere.rel_enterprise_id = ed_ei.enterprise_id'); $contractInfoList = $this->model->field('enterprise_id,enterprise_name') ->table(array('enterprise_data.yunkh_enterprise_info' => 'ed_id')) ->where($where) ->union(array('field'=>'ed_ei.enterprise_id,enterprise_name','table'=>$table2,'where'=>$where2),true) ->select(); return $contractInfoList; 执行的sql: SELECT 'enterprise_id','enterprise_name' FROM enterprise_data.yunkh_enterprise_info 'ed_id' WHERE 'enterprise_id' = 1 AND 'enterprise_name' LIKE '%农%' UNION ALL SELECT ed_ei.enterprise_id,'enterprise_name' FROM enterprise_data.yunkh_enterprise_rel_enterprise 'ed_ere',enterprise_data.yunkh_enterprise_info 'ed_ei' WHERE ed_ere.enterprise_id = 1 AND 'status' = '1' AND ed_ei.enterprise_name LIKE '%农%' AND ( ed_ere.rel_enterprise_id = ed_ei.enterprise_id )
张家口网站建设公司创新互联,张家口网站设计制作,有大型网站制作公司丰富经验。已为张家口上千余家提供企业网站建设服务。企业网站搭建\成都外贸网站制作要多少钱,请找那个售后服务好的张家口做网站的公司定做!
分享标题:thinkphp3.2unionall
分享链接:http://myzitong.com/article/joccih.html