diff --git a/application/models/Admins_model.php b/application/models/Admins_model.php index 98bf91fe..364d7646 100644 --- a/application/models/Admins_model.php +++ b/application/models/Admins_model.php @@ -156,12 +156,14 @@ class Admins_model extends EA_Model { */ public function validate_username($username, $user_id) { - $num_rows = $this->db->get_where('user_settings', [ - 'username' => $username, - 'id_users !=' => $user_id - ])->num_rows(); + if ( ! empty($user_id)) + { + $this->db->where('id_users !=', $user_id); + } - return $num_rows > 0 ? FALSE : TRUE; + $this->db->where('username', $username); + + return $this->db->get('user_settings')->num_rows() === 0; } /** diff --git a/application/models/Providers_model.php b/application/models/Providers_model.php index bf708bef..5a7f7145 100755 --- a/application/models/Providers_model.php +++ b/application/models/Providers_model.php @@ -187,9 +187,14 @@ class Providers_model extends EA_Model { */ public function validate_username($username, $user_id) { - $num_rows = $this->db->get_where('user_settings', - ['username' => $username, 'id_users != ' => $user_id])->num_rows(); - return $num_rows > 0 ? FALSE : TRUE; + if ( ! empty($user_id)) + { + $this->db->where('id_users !=', $user_id); + } + + $this->db->where('username', $username); + + return $this->db->get('user_settings')->num_rows() === 0; } /** diff --git a/application/models/Secretaries_model.php b/application/models/Secretaries_model.php index 6802923d..9f28a44f 100644 --- a/application/models/Secretaries_model.php +++ b/application/models/Secretaries_model.php @@ -164,9 +164,14 @@ class Secretaries_model extends EA_Model { */ public function validate_username($username, $user_id) { - $num_rows = $this->db->get_where('user_settings', - ['username' => $username, 'id_users != ' => $user_id])->num_rows(); - return $num_rows > 0 ? FALSE : TRUE; + if ( ! empty($user_id)) + { + $this->db->where('id_users !=', $user_id); + } + + $this->db->where('username', $username); + + return $this->db->get('user_settings')->num_rows() === 0; } /**