Codeigniter Active Query:多次更新同一列不同的行不同的ID
Codeigniter Active Query: Multiple Update same column different row different Where ID
花了几个小时和大量 google 搜索,我仍然无法解决这个问题。
请帮助检查我在这段代码中做错了什么:
$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)));
第一个更新成功并更新 table。但是,第二次更新对 table.
没有影响
请帮助正确的方向。
我真的希望这真的足够清楚,可以让我得到帮助。
谢谢大家。
这样做;
$s_Update = array('quantity' => ($product->quantity+$inventory->qty_per_box));
$this->db->where('id',$inventory->ea_id);
$this->db->update('products',$s_Update);
$quantity = $product->quantity-1;
$data = array('quantity'=> $quantity);
$this->db->where('id', $inventory->box_id);
$this->db->update('products', $data);
花了几个小时和大量 google 搜索,我仍然无法解决这个问题。 请帮助检查我在这段代码中做错了什么:
$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)));
第一个更新成功并更新 table。但是,第二次更新对 table.
没有影响请帮助正确的方向。
我真的希望这真的足够清楚,可以让我得到帮助。
谢谢大家。
这样做;
$s_Update = array('quantity' => ($product->quantity+$inventory->qty_per_box));
$this->db->where('id',$inventory->ea_id);
$this->db->update('products',$s_Update);
$quantity = $product->quantity-1;
$data = array('quantity'=> $quantity);
$this->db->where('id', $inventory->box_id);
$this->db->update('products', $data);