0

I am doing an ajax call..which doesnt output any mysql errors..Basically, I am trying to delete two records...

  public function task_delete($task_id)
     {
            $this->load->database();
            $this->db->delete('task_pages', array('id' => $task_id));
            $this->db->delete('tasks', array('id' => $task_id));

       }

This is the model..

And this is the controller..

class Ajax extends CI_Controller {

       public function delete()
      {
          $this->load->database();
          $this->load->model('tasks_model','task_delete');
          $result=$this->task_delete-> task_delete($this->input->post('myId'));
          echo $result;
      }

}

Where does my code fails?

UPDATE: I get an error..the method deleteTask is being called on none object

1
  • Your function is task_delete, but you're calling deleteTask. Commented Apr 16, 2012 at 13:57

1 Answer 1

4

Assuming your model is also called task_delete and the function you want to call is deleteTask, then you have given the function in your model the wrong name, it should be declared as this:

public function deleteTask($task_id)
Sign up to request clarification or add additional context in comments.

2 Comments

i fixed that it says that the where method is called on non object
Have you loaded the model into your app/controller? $this->load->model('task_delete'); or if you controller isn't called task_delete, $this->load->model('Model_name', 'task_delete');. Taken from codeigniter.com/user_guide/general/models.html

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.