Fixed the validate_username model method.

This commit is contained in:
Alex Tselegidis 2020-12-08 11:00:31 +02:00
parent 9655feca6c
commit 0631dbadf9
3 changed files with 23 additions and 11 deletions

View file

@ -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;
}
/**

View file

@ -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;
}
/**

View file

@ -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;
}
/**