我需要用一些值减去'stk_on_hand'字段的值并更新它。为此我尝试过的是
$this->db->select('co_q_id,co_stk_id,co_req_quantity');
$this->db->from('customer_order');
$this->db->where('co_num',1);
$result=$this->db->get();
foreach($result->result() as $row){
$stkArray[] = array(
'stk_id'=>$row->co_stk_id,
'stk_on_hand' =>'stk_on_hand - ' . (int) $row->co_req_quantity
);
$this->db->update_batch('ms_stock_list',$stkArray, 'stk_id');
但是执行此操作后,我得到的 'stk_on_hand' 为 0。请有人帮忙。
最佳答案
首先检查您的数据库列,如果“stk_on_hand”是 varchar 第二撤销前面的(int)
$row->co_req_quantity
关于mysql - 更新数据库中的列值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41504970/