Hi guys, I just want to ask how can I perform a batch update using arrays in CodeIgniter Here is my sample code:
public function updateItemInfo(){ $id = $this->input->post('idx'); //array of id $desc = $this->input->post('itemdesc'); //array of item name $qty = $this->input->post('qty'); //array or qty $price = $this->input->post('price'); //array of price $code = $this->input->post('codes'); // not array for($x = 0; $x < sizeof($id); $x++){ $total[] = $price[$x] * $qty[$x]; $updateArray = array( 'item_desc' => $desc[$x], 'item_qty' => $qty[$x], 'price' => $price[$x], 'total' => $total ); $this->db->where('poid',$id[$x]); $this->db->update('po_order_details',$updateArray); //Could not update I don't know why } //echo "<pre>"; //print_r($updateArray); $sumoftotal = array_sum($total); $vat_amt = $sumoftotal / 1.12; $vat_input = $vat_amt * 0.12; $total_all = $vat_amt + $vat_input; $updateTotal = array( 'vatable_input' => $vat_amt, 'vatable_amount' => $vat_input, 'total_amount_due' => $total_all ); //echo "<pre>"; //print_r($updateTotal); //exit; $this->db->where('order_code',$code); $this->db->update('po_order_total',$updateTotal); //Here also couldn't update }
What is my code And I canβt understand where my error is. Ia also checked my array values ββand there is no error in my array. My problem is that I cannot update my table using batch update.
codeigniter
Jerielle
source share