Welcome Guest, Not a member yet? Register   Sign In
You must use the "set" method to update an entry.
#1

(This post was last modified: 11-26-2016, 04:51 PM by shahriyar3.)

i have this error on update query
You must use the "set" method to update an entry.
codeigniter version 3.1
how to fix it?

controller

PHP Code:
public function ajax_update()
 
   {
 
       $this->_validate();
 
       if ($this->input->post('remove_photo') AND empty($_FILES['photo']['name'])) {
 
           $data['error_string'][] = 'انتخاب عکس اجباری است';
 
           $data['inputerror'][] = 'photo';
 
           $data['status'] = FALSE;
 
       }
 
       $data = array(
 
           'title' => $this->input->post('title'),
 
           'sub_title' => $this->input->post('sub_title'),
 
           'message' => $this->input->post('message',FALSE),
 
           //'captcha' => $this->input->post('captcha'),
 
           'tarikh' => time("NOW")
 
       );


 
       if ($this->input->post('remove_photo')) // if remove photo checked
 
       {
 
           if (file_exists(base_url() . 'assets/img/' $this->input->post('remove_photo')) && $this->input->post('remove_photo'))
 
               unlink(base_url() . 'assets/img/' $this->input->post('remove_photo'));
 
           $data['image'] = '';
 
       }

 
       if (!empty($_FILES['photo']['name'])) {
 
           $upload $this->_do_upload();

 
           //delete file
 
           $person $this->person->get_by_id($this->table$this->input->post('id'), $this->where);
 
           if (file_exists(base_url() . 'assets/img/' $person->image) && $person->image)
 
               unlink(base_url() . 'assets/img/' $person->image);

 
           $data['image'] = $upload;
 
       }
 
       $where = ['id' => $this->input->post('id'), 'position' => $this->position];
 
       print_r($data);
 
       $num $this->person->update($this->table$where$data);

 
       $this->logfile->message('product''''update id'.$this->input->post('id'));
 
       echo json_encode(array("status" => TRUE'number affected rows' => $num));
 
   

model
PHP Code:
public function update($table$where$data)
 
   {
 
       $this->db->where($where);
 
       echo $this->db->get_compiled_update($table$data);
 
       return $this->db->affected_rows();
 
   
Reply


Messages In This Thread
You must use the "set" method to update an entry. - by shahriyar3 - 11-26-2016, 04:42 PM



Theme © iAndrew 2016 - Forum software by © MyBB