Welcome Guest, Not a member yet? Register   Sign In
Issue with updateBatch method
#1

(This post was last modified: 10-30-2023, 11:38 AM by ozornick. Edit Reason: Reformat code )

Hi,
I have a DB table named 'products'. It has the following columns:  id, stock_shipped, stock_on_hand
I am facing some issues in using the updateBatch method.
When an order is placed, the stock should update properly for all the items/products in the order.
So I need to increase/decrease the existing value in DB table columns: stock_shipped and stock_on_hand

Code:

PHP Code:
$data[0]['id'] = 100;
$data[0]['stock_shipped'] = stock_shipped 10;
$data[0]['stock_on_hand'] = stock_on_hand 10;

$data[1]['id'] = 101;
$data[1]['stock_shipped'] = stock_shipped 25;
$data[1]['stock_on_hand'] = stock_on_hand 25;
...
...
...


$builder $this->db->table('products');
$builder->updateBatch($data'id'); 


Can you please suggest a way to use the same method: updateBatch correctly?
Reply


Messages In This Thread
Issue with updateBatch method - by ashlythomas - 10-30-2023, 05:23 AM
RE: Issue with updateBatch method - by luckmoshy - 10-30-2023, 08:39 PM
RE: Issue with updateBatch method - by kenjis - 10-31-2023, 03:32 AM



Theme © iAndrew 2016 - Forum software by © MyBB