当前位置 : 主页 > 网络编程 > PHP >

根据表中取到的不同表的id查id对应的值,放到一个数组统一return

来源:互联网 收集:自由互联 发布时间:2021-06-28
取数据库不同表的值统一返回 public function sel_production_details($id){// 取到详情工序表中的所有信息,根据传过来的产品id$date['arr'] = $this-db-select('production_details_id,production_list_id,ps_id,produc
取数据库不同表的值统一返回
public function sel_production_details($id)
	{
		// 取到详情工序表中的所有信息,根据传过来的产品id
		$date['arr'] = $this->db
		->select('production_details_id,production_list_id,ps_id,production_personnel_id,plan_work_hours,production_start_time,production_end_time,production_state,production_remark,inspector_id')
		->where('production_list_id',$id)
		->get('production_details')
		->result_array();
		
		//根据上面取到值里的一些别的表的id,取该id下所对应的值
		foreach ($date['arr'] as $k=>$v){
			$date['arr'][$k]['ps_name'] = $this->sel_ps_name($v['ps_id']);
			$date['arr'][$k]['ps_superior_id'] = $this->sel_ps_superior_id($v['ps_id']);
			$date['arr'][$k]['quality_testing_status'] = $this->sel_quality_testing_status($v['production_details_id']);
			$date['arr'][$k]['quality_testing_remark'] = $this->sel_quality_testing_remark($v['production_details_id']);
			$date['arr'][$k]['quality_testing_time'] = $this->sel_quality_testing_time($v['production_details_id']);
			$date['arr'][$k]['realname'] = $this->sel_realname($v['production_personnel_id']);
			$date['arr'][$k]['inspector_name'] = $this->sel_inspector_id($v['inspector_id']);
		}

        return $date;
    }  

    // 根据工序id 工序名称
    public function sel_ps_name($id)
	{
		$ps_name = $this->db
		->where('ps_id',$id)
		->get('procedure_setting')
		->row_array()['ps_name'];
		
		if (empty($ps_name)) {
			return '';
		}else{
			return $ps_name;
		}
	}
网友评论