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); }
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); }
public ERUser GetUser() { AssertIsSaved(); return(ERUser.Get(_userID)); }
public ERUser GetUser() { return(ERUser.Get(_userID)); }