안녕 얘들 아 내가 어떻게 여기 내 예제 코드의 CodeIgniter의 의 배열을 사용하여 일괄 업데이트를 수행 할 수 있습니다Codeigniter 배열을 사용하여 배치 업데이트를 수행하는 방법은 무엇입니까? 난 그냥 물어보고 싶은
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
}
내 코드입니다 그리고 내 오류 어디 나는 그것을 알아 냈 수 없습니다. 또한 배열 값을 검사했는데 배열에 오류가 없습니다. 내 문제는 일괄 업데이트를 사용하여 내 테이블을 업데이트 할 수 없다는 것입니다. http://ellislab.com/codeigniter/user-guide/database/active_record.html
CodeIgniter의 3.x를 : http://www.codeigniter.com/user_guide/database/query_builder.html?highlight=where#CI_DB_query_builder::update_batch
당신은 모든 옵션으로 array
를 만들 수 있습니다 후가 batch_update
기능에 보내
쓰기 '$ 에코 this-> DB-> last_query() 다이;'이 줄 이후'$ this-> DB-> 업데이트 ('po_order_details'$ updateArray); // 어떤 쿼리가 생성되는지 보려면 왜 업데이트 할 수 없습니다 '라는 오류 메시지가 나타납니다. –