CodeIgniter Forums
Please allow update_batch with multiple keys - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17)
+--- Thread: Please allow update_batch with multiple keys (/showthread.php?tid=77793)



Please allow update_batch with multiple keys - huangnam - 10-19-2020

Example:
I have a MySQL table order_details (order_id, product_id, price).
Keys are: order_id and product_id.

Codeigniter should allow update batch with multiple keys like this:

PHP Code:
$data = array(
array(
'order_id' => 1,
'product_id' => 1,
'price' => 99
),
array(
'order_id' => 1,
'product_id' => 2,
'price' => 80
)
);
$this->db->update_batch('order_details'$data, array('order_id''product_id') ); 

Please add this feature.


RE: Please allow update_batch with multiple keys - iy4nl4mp - 10-19-2021

(10-19-2020, 06:43 PM)huangnam Wrote: Example:
I have a MySQL table order_details (order_id, product_id, price).
Keys are: order_id and product_id.

Codeigniter should allow update batch with multiple keys like this:

PHP Code:
$data = array(
array(
'order_id' => 1,
'product_id' => 1,
'price' => 99
),
array(
'order_id' => 1,
'product_id' => 2,
'price' => 80
)
);
$this->db->update_batch('order_details'$data, array('order_id''product_id') ); 

Please add this feature.

For this solution I use a method like this Mr., you can try, with a declaration like the one below
and this worked for more than 1 condition.

$this->db->where('product_id','2323');
$this->db->update_batch('erp_manag_md_hargabarang', $data,'order_id');