2016-05-29 74 views
0

我試圖找到一種方法來驗證我的刪除查詢成功。我怎樣才能從以下結構NUM_ROWS或affected_rows:num_rows刪除查詢codeigniter

public function fire_db($currentUserID, $id_staff){ 
     $this->db->where('id_player', $currentUserID); 
     $this->db->where('id_hired_staff', $id_staff); 
     $this->db->limit(1); 
     $this->db->delete('game_hired_staff'); 
     if ($this->db->num_rows() == 1) { 
      return true; 
     } 
     else 
      return false; 
    } 

使用笨3

回答

1

測試刪除查詢使用

$this->db->affected_rows(); 
0

的結果,嘗試這樣

public function fire_db($currentUserID, $id_staff){ 
    $this->db->where('id_player', $currentUserID); 
    $this->db->where('id_hired_staff', $id_staff); 
    $this->db->limit(1); 

    if (!$this->db->delete('game_hired_staff')) { 
     return false; 
    } 
    else 
     print_r($this->db->affected_rows());    
    } 

可能重複的codeigniter db->delete() returns true always?