Пример #1
0
        public static ERUser Get(string username)
        {
            ERUser result = null;

            MySqlConnection conn = DB.Connection();

            conn.Open();

            MySqlCommand cmd = conn.CreateCommand() as MySqlCommand;

            cmd.CommandText = $"SELECT id, username FROM users WHERE username = @Username;";

            MySqlParameter nameParam = new MySqlParameter();

            nameParam.ParameterName = "@Username";
            nameParam.Value         = username;
            cmd.Parameters.Add(nameParam);

            MySqlDataReader rdr = cmd.ExecuteReader() as MySqlDataReader;

            while (rdr.Read())
            {
                int    newID       = rdr.GetInt32(0);
                string newUsername = rdr.GetString(1);

                result = new ERUser(newUsername, newID);
            }

            DB.Close(conn);

            return(result);
        }
Пример #2
0
        public static ERUser Get(int id)
        {
            ERUser result = null;

            MySqlConnection conn = DB.Connection();

            conn.Open();

            MySqlCommand cmd = conn.CreateCommand() as MySqlCommand;

            cmd.CommandText = $"SELECT id, username FROM users WHERE id = {id};";

            MySqlDataReader rdr = cmd.ExecuteReader() as MySqlDataReader;

            while (rdr.Read())
            {
                int    newID    = rdr.GetInt32(0);
                string username = rdr.GetString(1);

                result = new ERUser(username, newID);
            }

            DB.Close(conn);

            return(result);
        }
Пример #3
0
 public ERUser GetUser()
 {
     AssertIsSaved();
     return(ERUser.Get(_userID));
 }
Пример #4
0
 public ERUser GetUser()
 {
     return(ERUser.Get(_userID));
 }