phpmysqlcodeigniteractiverecordsql-delete

num_rows on delete query codeigniter


I'm trying to find a way to validate that my Delete query was successful. How can I get num_rows or affected_rows from the following structure:

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;
    }

Using codeigniter 3


Solution

  • to test result of delete query use

    $this->db->affected_rows();