php - array to string conversion error in codeigniter 3.0.1 -
i have following error message while updating records in database
severity: notice
message: array string conversion
filename: database/db_query_builder.php
line number: 662
backtrace:
file: c:\xampp\htdocs\site\application\models\class_model.php line: 48 function: where
file: c:\xampp\htdocs\site\application\controllers\class_con.php line: 107 function: update
file: c:\xampp\htdocs\site\index.php line: 292 function: require_once
here controller
function edit($id) { $rules = [ [ 'field' => 'classname', 'label' => 'class name', 'rules' => 'trim|required' ], [ 'field' => 'inchargename', 'label' => 'incharge name', 'rules' => 'trim|required' ], [ 'field' => 'classstrength', 'label' => 'class strength', 'rules' => 'trim|required' ] ]; $this->form_validation->set_rules($rules); $class = $this->class_model->find($id)->row(); if($this->form_validation->run() == false) { $this->load->view('admin/class/classedit',array('class'=>$class)); } else { $data['classname'] = set_value('classname'); $data['inchargename'] = set_value('inchargename'); $data['classstregth'] = set_value('classstregth'); $this->class_model->update($id,$data); $this->session->set_flashdata('message','class has been updated successfully'); redirect('class_con/index'); } }
and here's model
public function find($id) { $this->db->where('id',$id); $row = $this->db->get('class'); return $row; } function update($data, $id) { try{ $this->db->where('id',$id); $this->db->update('class', $data); return true; } catch(execption $e){ echo $e->getmessage(); } }
and here view
<?php echo form_open_multipart('class_con/edit/'.$class->id); ?> <div class="form-group" id="register-login-group"> <label for="classname">class name</label> <div class="input-group"> <input type="text" class="form-control" id="classname" name="classname" value="<?php echo $class->classname; ?>" placeholder="class name"> <div class="input-group-addon"><i class="fa fa-pencil"></i></div> </div> </div> <div class="form-group" id="register-login-group"> <label for="classname">incharge name</label> <div class="input-group"> <input type="text" class="form-control" id="inchargename" name="inchargename" value="<?php echo $class->inchargename; ?>" placeholder="incharge name"> <div class="input-group-addon"><i class="fa fa-pencil"></i></div> </div> </div> <div class="form-group" id="register-login-group"> <label for="classname">class strength</label> <div class="input-group"> <input type="text" class="form-control" id="classstrength" name="classstrength" value="<?php echo $class->classstrength; ?>" placeholder="class stregth"> <div class="input-group-addon"><i class="fa fa-pencil"></i></div> </div> </div> <button type="submit" class="btn btn-primary">save</button> <?=anchor('class_con/index','cancel',['class'=>'btn btn-warning'])?> <?php echo form_close(); ?>
in controller call update method in model line :
$this->class_model->update($id,$data);
but in model have defined function :
function update($data, $id) { try{ $this->db->where('id',$id); $this->db->update('class', $data); return true; } catch(execption $e){ echo $e->getmessage(); } }
the problem order of parameter's have passed :
change :
$this->class_model->update($data,$id);
Comments
Post a Comment