[eluser]AdonisSMU[/eluser]
This is the function from my controller.
Code:
function manage_user($id)
{
$this->load->model('musers');
$this->load->model('muserprofile');
$user_update = $this->input->post('user_update');
$data['title'] = 'H.P.N. White Label by TEN || User Update Area';
$data['main_content'] = 'manage_user';
$data['login'] = $this->musers->getUser($id);
$data['info'] = $this->muserprofile->getUserProfile($id);
if ($user_update == true) {
$user['email'] = $data['login']['email'];
$user['username'] = $data['login']['username'];
$profile['first_name'] = $data['info']['first_name'];
$profile['last_name'] = $data['info']['last_name'];
$profile['company_name'] = $data['info']['company_name'];
$profile['salutation'] = $data['info']['salutation'];
$profile['title'] = $data['info']['title'];
$profile['street_address'] = $data['info']['street_address'];
$profile['city'] = $data['info']['city'];
$profile['state'] = $data['info']['state'];
$profile['zip'] = $data['info']['zip'];
$profile['country'] = $data['info']['country'];
$profile['phone'] = $data['info']['phone'];
$login_result = $this->musers->updateUser($id, $user);
$profile_result = $this->muserprofile->updateUserProfile($id, $profile);
if ($login_result && $profile_result) {
$data['msg'] = "User profile updated.";
$data['status'] = "success";
} else {
$data['msg'] = "Sorry, user profile not updated.";
$data['status'] = "error";
}
} else {
$data['msg'] = "";
$data['status'] = "";
}
$this->load->view('includes/template', $data);
}
This is the function from my model.
Code:
function updateUser($id, $users)
{
$this->db->where('id', $id);
$this->db->update('users', $users);
$result = $this->db->affected_rows();
if($result == 1) {
return true;
} else {
return false;
}
}
The $result in the updateUser function is 0 for rows affected and I checked the database and the id matches. Can anyone please help me figure out what I am missing here? Thanks!