Dmitry Makovetskiyd
Dmitry Makovetskiyd

Reputation: 7053

CodeIgniter deleting with db doesnt work

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

Upvotes: 0

Views: 94

Answers (1)

cchana
cchana

Reputation: 4990

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)

Upvotes: 4

Related Questions