XxnumbxX
XxnumbxX

Reputation: 134

Codeigniter Arithmetic inside of set statement

I am trying to update a field in my table with values from array key, below is statement but I cannot get to work when using array key. I am new and likely not creating the statement correctly. Any help is appreciated.

$this->db->set('product_qoh', 'product_qoh - $item['sold']' ,FALSE);

Upvotes: 1

Views: 46

Answers (1)

XxnumbxX
XxnumbxX

Reputation: 134

Below worked for me, the above was replacing the cell value with the negate of $item['sold'].

$this->db->set('product_qoh', 'product_qoh - '  .$item['sold'] ,FALSE);

Upvotes: 2

Related Questions