简体   繁体   中英

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

假设您的模型也称为task_delete,而您要调用的函数是deleteTask,那么您给模型中的函数指定了错误的名称,应将其声明为:

public function deleteTask($task_id)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM