花了幾個小時和衆多谷歌搜索,我仍然無法得到這個解決方案。 請幫助檢查什麼,我在此代碼做錯了:Codeigniter主動查詢:多個更新相同的列不同的行不同在哪裏ID
$product = $this->site->getProductByID($item['product_id']);
$inventory = $this->site->getInventoryByID($product->id);
if($pp_up === TRUE && (($product->quantity < 0) && ($product->parent_id != 0) && ($inventory->box_qty != 0)) === TRUE){
$s_Update = array(
'quantity' => ($product->quantity+$inventory->qty_per_box),
'id' => $inventory->ea_id
);
$this->db->where('id',$inventory->ea_id);
$this->db->update('products',$s_Update);
// the query runs successfully up till here------------------------------------
/*This Never perform any update */
if($this->db->affected_rows() > 0){
$this->db->update('products', array('quantity' => ($product->quantity-1), array('id' => $inventory->box_id)));
第一次更新工作順利,並根據更新表。但是,第二次更新對錶格沒有影響。
請幫助正確的方向。
我真的很希望這真的很清楚,能夠幫助我。
謝謝你們。
表中數量字段的數據類型是不是整數? – pradeep
quantity is varchar not integer –
put this $ sql ='update products set quantity ='。($ product-> quantity-1)。'其中id ='。$ inventory-> box_id;之前更新查詢和回聲這個SQL來看看輸出是什麼 – pradeep