Search code examples
codeigniterwhere-clauseupdating

update record with codeigniter active record


In my controller, I am calling a model function with the following:

$this->sales_model->softdelete_order($this->input->post('ordernumber'));

what I want to do, in my model is

update Customer_Order_Summary set Deleted='1' where CustomerOrderID='123'

where 123 is $this->input->post('ordernumber')

My Model syntax is:

  function softdelete_order($q){
    $this->db->set('Deleted','1');
    $this->db->where('CustomerOrderID', $q);
    $query = $this->db->update('Customer_Order_Summary');
  }

This is not working or outputting any errors.

The model is preloaded and the post information is posting and echoing correctly so purely a model syntax issue I think.

Help appreciated as always.

Thanks,


Solution

  • After

    $query = $this->db->update('Customer_Order_Summary');
    

    add

    $this->db->last_query();
    

    to see your query and you can repair it from there.