function generateNewUserId() { $commons = new Commons(); $randomString = $commons->generateRandomString(10); $query = "\n\t\t\tSELECT * FROM " . TAB_USERS . " \n\t\t\tWHERE \t" . COL_USER_ID . " = '{$randomString}' "; $result = $this->mysqli->query($query); if (!$this->mysqli->connect_errno) { if ($result->num_rows == 1) { return $this->generateNewUserId(); } else { return $randomString; } } return false; }