I am new to Codeigniter. I’m trying to create a simple customer database and when it keeps trying to load my update_customer model It keeps giving me a Http error 500. I’m pretty sure I’ve narrowed it down to the model cause when I comment out the model call the page redirects it to itself with no error. Any ideas where my mistake was?
and I can’t seem to find the error in the apache error logs…
CONTROLLER:
function edit_customer($id){
$data['success']=0;
if($_POST){
$data_customer=$_POST;
$data_customer['active'] = 1;
$this->customer->update_customer($id,$data);
$data['success']=1;
}
$data['customer']=$this->customer->get_customer($id);
$this->load->view('header');
$this->load->view('edit_customer',$data);
$this->load->view('footer');
}
MODEL:
function get_customer($id){
$this->db->select()->from('customers')->where(array('active'=>1, 'id'=>$id))->order_by('date_added', 'desc');
$query=$this->db->get();
return $query->first_row('array');
}
function update_customer($id, $data){
$this->where('id', $id);
$this->db->update('customers', $data);
}
Your missing a
db->in your where statement should be: