配列のループを作成し、次は更新バッチですが、1 つの項目を更新しようとするとコードが更新されません。エラーがどこにあるのかわかりません。簡単な方法で更新バッチを実行するにはどうすればよいですか?
これが私のコードです:
/*THIS IS ALL ARRAY*/
$id = $this->input->post('idx');
$desc = $this->input->post('itemdesc');
$qty = $this->input->post('qty');
$price = $this->input->post('price');
$status = $this->input->post('status');
for($x = 0; $x < sizeof($id); $x++){
$total[] = $price[$x] * $qty[$x];
$updateArray[] = array(
'poid' => $id[$x],
'item_desc' => $desc[$x],
'item_qty' => $qty[$x],
'price' => $price[$x],
'total' => $total[$x],
'status' => $status[$x]
);
$this->db->update_batch('po_order_details',$updateArray, 'poid'); //I guess poid is my error but im not sure. I think my array won't find the correct id for where.
}
配列のサンプル出力は次のとおりです。
Array
(
[0] => Array
(
[poid] => 5
[item_desc] => Yakisoba
[item_qty] => 15
[price] => 40,000.00
[total] => 600
[status] => ACTIVE
)
[1] => Array
(
[poid] => 6
[item_desc] => Laptop
[item_qty] => 5
[price] => 15,000.00
[total] => 75
[status] => ACTIVE
)
[2] => Array
(
[poid] => 7
[item_desc] => Speaker
[item_qty] => 3
[price] => 5,000.00
[total] => 15
[status] => ACTIVE
)
[3] => Array
(
[poid] => 8
[item_desc] => Mouse
[item_qty] => 5
[price] => 500.00
[total] => 2500
[status] => ACTIVE
)
[4] => Array
(
[poid] => 9
[item_desc] => Keyboard
[item_qty] => 5
[price] => 1,000.00
[total] => 5
[status] => ACTIVE
)
)
それがすべての人です。あなたが私を助けてくれることを願っています。