0

If i remember correctly, i have tested this function a month ago and its working. Now its not.

This is the model :

function delete($table, $id) {
    $query = $this->db->delete($table, array('id'=>$id));
    //return $this->db->affected_rows();
    return $query;
}

And i use it on my controller :

 $schedule_id = $this->post('id');
   $result = $this->schedule_m->delete('schedule', $schedule_id);
   if($result == true )
        {
            $this->response(array('result' => 'true'), 200);
        }

The response is always true, but the row is never deleted.

I tried to return $this->db->affected_rows(); and use var_dump, the result is int(0).

Please kindly help me. Thanks for your time.

1 Answer 1

2

Try with WHERE condition like

function delete($table, $id) {
    $this->db->where('id' , $id);
    $query = $this->db->delete($table);
}

And also check whether the table still have the same field id.

Sign up to request clarification or add additional context in comments.

1 Comment

Its working now..i dont know what happened @@. I will accept your answer in 9 minutes (SO's system). Thanks a lot

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.