我是 codeigniter 的新手,并且正在从事一个我必须更新用户记录的 codeignter 项目。传递给模型的用户 id 和数据是正确的,但是当我更新记录时,所有用户都更新为新记录。我的编码是:
public function updateUser(){
$user = $this->session->userdata('logged_in');
$userID = $user['id'];
$data = array(
"first_name" => $this->input->post('reg_first_name'),
"last_name" => $this->input->post('reg_last_name'),
"mobile" => $this->input->post('reg_mobile'),
"country" => $this->input->post('reg_country'),
"state" => $this->input->post('reg_state'),
"city" => $this->input->post('reg_city'),
"paypal_email" => ''
);
$this->db->update('users',$data);
$this->db->where('id',$userID);
if($this->db->affected_rows() > 0){
return true;
}
else {
return false;
}
}
我的代码有问题吗,请帮忙。