我如何在每次处理时增加我的qty值,而不仅仅是更新它?
$prodid = $this->input->post('product')[$x];
if($prodid){
$product_quanti = array(
'qty' => $this->input->post('qty')[$x],
);
$this->db->where('id', $prodid);
$update = $this->db->update('products', $product_quanti);
}我试过这个
$prodid = $this->input->post('product')[$x];
if($prodid){
$product_quanti = array(
'qty' => $this->input->post('qty')[$x] + $this->input->post('qty')[$x],
);
$this->db->where('id', $prodid);
$update = $this->db->update('products', $product_quanti);
}但是每次我处理它时,它只是随机地增加一个数字i,数量是200,当我输入500,它随机返回1000,我怎么能以正确的方式增加它呢?
我怎样才能使有价证券+进货股票公式?
发布于 2022-12-03 09:48:42
您正在将值设置为输入的两倍,而不是当前值+输入。所以500的结果是1000。
相反,你可以做这样的事情:
$inputQuantity = (int)$this->input->post('qty')[$x];
$this->db->where('id', $prodid);
$this->db->set('qty', "qty+$inputQuantity", false);
$this->db->update('products');https://stackoverflow.com/questions/74665488
复制相似问题