How to edit two columns using codeigniter
I want to ask my program. I wanted to edit but can't edit in jurnal table and bahan_baku table has been edited successfully. please save me. I have 2 tables.
table bahan_baku id_bahanbaku keterangan_bb tanggal_bb jumlah_bb harga_bb
jurnal table id_jurnal id_coa tanggal Debit Kredit
this my model -> m_bahanbaku.php
function m_edit($data_bb){
$this->db->where($data_bb);
$edit_bb = $this->db->get('bahan_baku');
return $edit_bb->result();
$this->db->where($data_jurnal);
$edit_jurnal = $this->db->get('jurnal');
return $edit_jurnal->result();
}
function m_update($data_bb, $id_bahanbaku,$data_jurnal, $id_coa){
$this->db->where('id_bahanbaku', $id_bahanbaku); //untuk tabel bahan_baku
$this->db->update('bahan_baku', $data_bb);
$this->db->where('id_jurnal', $id_jurnal); //dari tabel jurnal
$this->db->update('jurnal', $data_jurnal);
}}
and this my controller -> bahanbaku.php
function edit($id_bahanbaku){
$data_bb=array(
'id_bahanbaku'=>$id_bahanbaku
);
$data_jurnal=array(
'id_jurnal'=>$id_bahanbaku
);
$data_bb['data_edit']=$this->m_bahanbaku->m_edit($data_bb, $data_jurnal);
$this->load->view('keuangan/v_edit_bb',$data_bb, $data_jurnal);
}
function update(){
$id_bahanbaku = $this->input->post('id_bahanbaku');
$data_bb=array(
'keterangan_bb' => $this->input->post('keterangan_bb'),
'tanggal_bb' => $this->input->post('tanggal_bb'),
'jumlah_bb' => $this->input->post('jumlah_bb'),
'harga_bb' => $this->input->post('harga_bb')
);
$id_jurnal = $this->input->post('id_jurnal');
$data_jurnal=array(
'tanggal' => $this->input->post('tanggal_bb'),
'debet'=>$this->input->post('harga_bb'),
'kredit'=>$this->input->post('harga_bb')
);
$this->m_bahanbaku->m_update($data_bb, $id_bahanbaku, $data_jurnal, $id_jurnal);
redirect(base_url().'keuangan/bahanbaku/lihat');
}
}
+3
source to share
2 answers
function m_update($data_bb, $id_bahanbaku,$data_jurnal, $id_coa){
$this->db->where('id_bahanbaku', $id_bahanbaku); //untuk tabel bahan_baku
$this->db->update('bahan_baku', $data_bb);
$this->db->where('id_jurnal', $id_coa); //dari tabel jurnal
$this->db->update('jurnal', $data_jurnal);
}
}
check my code and compare it with yours, i hope this solves your problem.
Hello
0
source to share