我正在使用邮递员。当我在邮递员中输入手机号码并在sql yog上检查它时,在那边更新了另一个号码。我不知道发生了什么。其他列数据运行正常,唯一的问题是移动字段。请帮忙.. 预先感谢。
this is what i got after executing the code
this is my controller file
function updt()
{
$input = (array)json_decode(file_get_contents('php://input'));
$this->form_validation->set_rules('id','id','trim|is_natural_no_zero|required');
$this->form_validation->set_rules('fname','fname','trim');
$this->form_validation->set_rules('lname','lname','trim');
$this->form_validation->set_rules('mobile','mobile','exact_length[10]');
$this->form_validation->set_rules('email','email','trim|valid_email');
$this->form_validation->set_rules('user','user','trim');
$this->form_validation->set_rules('password','password','trim');
$this->form_validation->set_data($input);
if($this->form_validation->run() == FALSE)
{
$out =['status'=>403, 'msg' =>$this->form_validation->error_array()];
$this->output->set_output(json_encode($out));
}
else
{
$data = array();
$data['id'] = $input['id'];
if(isset($input['fname'])) {$data['fname'] =$input['fname'];}
if(isset($input['lname'])) {$data['lname'] = $input['lname'];}
if(isset($input['mobile'])) {$data['mobile'] = $input['mobile'];}
if(isset($input['email'])) {$data['email'] = $input['email'];}
if(isset($input['user'])) {$data['user'] = $input['user'];}
if(isset($input['password'])) {$data['password'] = md5($input['password']);}
$up = $this->mym->updtdata($data);
if($up['status'] ==1)
{
$out = ['status'=>200, 'msg'=>'records uppdated'];
$this->output->set_output(json_encode($out));
}
else
{
$out = ['status'=>200, 'msg'=>'Records ont updated'];
$this->output->set_output(json_encode($out));
}
}
}
这是我的模型函数
function updtdata($update)
{
$this->db->where('id',$update['id']);
$query = $this->db->update('userdata',$update);
if($query)
{
return array('status'=>1);
}
else
{
return array('status'=>0, 'msg'=>'Error occurd');
}
}