Kenapa masih gagal Array Merge?

jadi saya punya 2 model yg isinya sama HANYA beda jenis,

 	function Perintahyear(){
		$sql="select year(tglSurat) as tahun, count(idSurat) as jumlah
				from pegawai join tmp_pegawai using(idPegawai)
				join surat s using(idSurat) where jenisSurat = 'SuratPerintah'
				group by year(tglSurat)";
		return $this->db->query($sql);
	}
	function Tugasyear(){
		$sql="select year(tglSurat) as tahun, count(idSurat) as jumlah1
				from pegawai join tmp_pegawai using(idPegawai)
				join surat s using(idSurat) where jenisSurat = 'SuratTugas'
				group by year(tglSurat)";
		return $this->db->query($sql);
	}

dari model tersebut saya panggil dicontrollernya

 $data_pegawai1=$this->m_laporan->Perintahyear()->result_array();
        $data_pegawai2=$this->m_laporan->Tugasyear()->result_array();
	//$data['data_pegawai']=(object)array_merge((array)$data_pegawai1,(array)$data_pegawai2);//ini blm bisa
	$data['data_pegawai']=array_merge($data_pegawai1,$data_pegawai2);
	//$data['data_pegawai']=$data_pegawai1+$data_pegawai2;

//ini blm bisa lalu viewnya

 <?php if(!empty($data_pegawai)){
	//print_r($data_pegawai);
?>
  <table class="table table-bordered" id="report" border="1" style="height:30px">
    <thead>
      <tr bgcolor="#EFEFEF">
        <td class="col-sm-2">No</td>
        <td class="col-sm-2">Tahun</td>
        <td class="col-sm-2">Jumlah Surat Perintah</td>
        <td class="col-sm-2">Jumlah Surat Tugas</td>
        <td class="col-sm-2">Total</td>
	</tr>
    </thead>
    <tbody>
      <?php $no = 0; ?>
	  <?php $total_surat = 0;
			$total_sp=0;
			$total_st=0;
			$total=0;
			$jumlah=0;
			$jumlah1=0;
			?>
	  <?php foreach($data_pegawai as $tampil):?>
      <?php $no++;
			if(empty($tampil['jumlah'])){
				$tampil['jumlah']=0;
				}
	  ?>
	  <?php $total_sp+=$tampil['jumlah'];  ?>
	  <?php $tampil['total']=0;
			if(!empty($tampil['jumlah1'])){
				//$tampil['jumlah1']=0;
				$total_st+=$tampil['jumlah1'];
				$tampil['total']=$tampil['jumlah']+$tampil['jumlah1'];
				}
			//	$total+=$tampil['total'];
			$total_surat=$total_sp+$total_st;
	  ?>
      <tr>
        <td><?= $no ?></td>
        <td><?= $tampil['tahun'] ?></td>
        <td><?= (!empty($tampil['jumlah']))?$tampil['jumlah']:'0' ?></td>
        <td><?= (!empty($tampil['jumlah1']))?$tampil['jumlah1']:'0'  ?></td>
		<td><?= $tampil['total'] ?></td>
			<?php endforeach;?>
	 </tr>
	  <tr>
        <td colspan="2">Total</td>
        <td><?php
				//$jumlah = 0;
				//foreach($data_pegawai as $a){
					//echo $a['jumlah']."-";
					echo $total_sp;
				//}
			?>
		</td>
        <td><?php
					echo $total_st;

			?></td>
        <td><?php  echo $total_surat;
		?></td>

      </tr>
    </tbody>
  </table>

saya sudah coba beberapa cara arraymerge tapi hasilna sama saja hasilnya sendiri"(tahun 2017 tertulis 2 kali) mohon bantuannya

avatar santytaurus
@santytaurus

4 Kontribusi 0 Poin

Dipost 7 tahun yang lalu

Belum ada Jawaban. Jadi yang pertama Jawaban

Login untuk ikut Jawaban