将数据作为数组连接代码点火器传递



拜托,当我想加入并操作 2 个查询时,任何人都可以帮助我修复将数据显示为数组的代码。

这是我的控制器:

public function pegawai()
{
$data['pegawai'] = $this->Ajax_model->pegawai_get();
$this->load->view('ajax/pegawai', $data);
}

这是我的模型:

//get modal search data
public function pegawai_get($pegawai_id = TRUE)
{
$this->db->select('m_riwayat_kepangkatan.*, m_pegawai.nip, m_pegawai.nama, r_golongan.golongan, r_golongan.jenis_pangkat');
$this->db->from('m_riwayat_kepangkatan');
$this->db->join('m_pegawai', 'm_pegawai.id = m_riwayat_kepangkatan.pegawai_id');
$this->db->join('r_golongan', 'r_golongan.id = m_riwayat_kepangkatan.golongan_id');
$this->db->order_by("pegawai_id", "asc");
$query1 = $this->db->get();
return $query1->result_array();
$this->db->select('m_riwayat_jabatan.*, m_pegawai.nip, m_pegawai.nama, m_opd.nama_opd, m_unit_kerja.unit_kerja');
$this->db->from('m_riwayat_jabatan');
$this->db->where("m_pegawai.id ='$pegawai_id'");
$this->db->join('m_pegawai', 'm_pegawai.id = m_riwayat_jabatan.pegawai_id');
$this->db->join('m_opd', 'm_opd.id = m_riwayat_jabatan.opd_id');
$this->db->join('m_unit_kerja', 'm_unit_kerja.id = m_riwayat_jabatan.unit_kerja_id');
$this->db->order_by("pegawai_id", "asc");
$query2 = $this->db->get();
foreach ($query2->result_array() as $row2){
//$pegawai_id    = $row2["pegawai_id"];
//$nip           = $row2["nip"];
//$nama          = $row2["nama"];
$nama_opd      = $row2["nama_opd"];
$unit_kerja    = $row2["unit_kerja"];
}
return $query2->result_array();
}

但我的数据看起来像这样:

"data": [
{
"id": "1",
"pegawai_id": "1",
"instansi": "null",
"keterangan_instansi": null,
"jenis_pegawai_id": "1",
"golongan_id": "null",
"tmt": "null",
"no_sk": "null",
"tgl_sk": "0000-00-00",
"penetap_sk": null,
"gaji_pokok": null,
"dasar_keputusan": null,
"scan_sk": null,
"is_verified": "1",
"input_tipe": "1",
"created_at": "2017-12-14 08:32:05",
"updated_at": "2018-02-20 09:05:07",
"nip": "197207032007011024",
"nama": "Abdullah",
"golongan": "null",
"jenis_pangkat": "null"
},

它只是查询 1 的显示值。我还想在数据中为 query2 取值,例如"nama_opd"和"unit_kerja"。看起来我错过了一些东西。

看看return $query1->result_array();.您已在第二次查询之前返回它

相关内容

  • 没有找到相关文章

最新更新