2017-01-06 72 views
0

列值,我需要一些价值减去的“stk_on_hand”字段中的值,并更新it.And这是我曾尝试是更新中DB

 $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'); 

但经过执行本我” m得到'stk_on_hand' as 。有人请帮忙。

回答

0

首先检查你的数据库列,如果 'stk_on_hand' 是

$row->co_req_quantity 
之前的VARCHAR revome的(INT)