我尝试在Codeigniter
HMVC中进行编码
控制器:
public function tambah_pembelian_proses($id) {
//menambahkan ke tabel pembelian
$data = array(
'tgl_beli' => $this->input->post('tgl_beli'),
'waktu' => $this->input->post('waktu'),
'nomor_po' => $this->input->post('nomor_po'),
'nomor_manual' => $this->input->post('nomor_manual'),
'id_koderek' => $this->input->post('id_koderek'),
'id_supplier' => $this->input->post('id_supplier'),
'subtotal' => $this->input->post('subtotal'),
'username' => $this->input->post('username')
);
$update = $this->db->update('pembelian',$data,array('nomor_po' => $id));
//end menambahkan ke tabel pembelian
//menambahkan ke tabel pembelian_sementara
$data4 = array(
'tgl_beli' => $this->input->post('tgl_beli'),
'waktu' => $this->input->post('waktu'),
'nomor_po' => $this->input->post('nomor_po'),
'nomor_manual' => $this->input->post('nomor_manual'),
'id_koderek' => $this->input->post('id_koderek'),
'id_supplier' => $this->input->post('id_supplier'),
'nama_user' => $this->input->post('nama_user'),
'subtotal' => $this->input->post('subtotal')
);
$insert = $this->db->insert('pembelian_sementara',$data4);
//end menambahkan ke tabel pembelian_sementara
//menambahkan ke tabel pembelian_detail
$nomor_po_beli = $_POST['nomor_po_beli'];
$kode_brg = $_POST['kode_brg'];
$nama_barang = $_POST['nama_barang'];
$satuan = $_POST['satuan'];
$hrg = $_POST['hrg'];
$beli_qty = $_POST['beli_qty'];
$beli_total = $_POST['beli_total'];
$user = $_POST['user'];
$data2 = array();
$index = 0;
foreach ($nomor_po_beli as $data_nomor_po_beli){
array_push($data2, array(
'nomor_po_beli' => $data_nomor_po_beli,
'kode_brg' => $kode_brg[$index],
'nama_barang' => $nama_barang[$index],
'satuan' => $satuan[$index],
'hrg' => $hrg[$index],
'beli_qty' => $beli_qty[$index],
'beli_total' => $beli_total[$index],
'user' => $user[$index]
));
//tambah stok
//$this->db->query("update barang set stock=stock+'$beli_qty[$index]' where kode_brg='$kode_brg[$index]'"); //Tambah Add Stock
$index++;
}
$insert_detail = $this->m_pembelian->simpan_pembelian_detail($data2);
//end menambahkan ke tabel pembelian_detail
//menambahkan ke tabel add_to_terima
$nomor_po_beli = $_POST['nomor_po_beli'];
$kode_brg = $_POST['kode_brg'];
$nama_barang = $_POST['nama_barang'];
$satuan = $_POST['satuan'];
$hrg = $_POST['hrg'];
$beli_qty = $_POST['beli_qty'];
$beli_total = $_POST['beli_total'];
$user = $_POST['user'];
$data3 = array();
$index = 0;
foreach ($nomor_po_beli as $data_nomor_po_beli){
array_push($data3, array(
'nomor_po_beli' => $data_nomor_po_beli,
'kode_brg' => $kode_brg[$index],
'nama_barang' => $nama_barang[$index],
'satuan' => $satuan[$index],
'hrg' => $hrg[$index],
'beli_qty' => $beli_qty[$index],
'beli_total' => $beli_total[$index],
'user' => $user[$index]
));
//tambah stok
//$this->db->query("update barang set stock=stock+'$beli_qty[$index]' where kode_brg='$kode_brg[$index]'"); //Tambah Add Stock
$index++;
}
$insert_terima = $this->m_pembelian->simpan_add_to_terima($data3);
//$insert_terima = $this->db->insert('add_to_terima',$data3,array('id_add_terima' => $id));
//end menambahkan ke tabel add_to_terima
if ($insert_detail){
$username_cart = $this->session->userdata("username");
$delete = $this->db->delete('add_to_cart',array('username_cart' => $username_cart));
} else {
redirect('pembelian/lihat_pembelian/'.$id);
}
redirect('pembelian/lihat_pembelian/'.$id);
}
结果是
遇到未捕获的异常
类型:ArgumentCountError
消息:函数Pembelian :: tambah_pembelian_proses()的参数太少,在第532行的C:\ xampp7.3.2 \ htdocs \ egupers \ system \ core \ CodeIgniter.php中传递了0,并且恰好期望1
文件名:C:\ xampp7.3.2 \ htdocs \ egupers \ application \ modules \ pembelian \ controllers \ Pembelian.php
行号:64
回溯:
文件:C:\ xampp7.3.2 \ htdocs \ egupers \ index.php 线:315 功能:require_once