Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.12 KB | None | 0 0
  1. public class Account : DatabaseTable
  2.     {
  3.         [PRIMARY_KEY]
  4.         [AUTO_INCREMENT]
  5.         [NOT_NULL]
  6.         public int id { get; set; }
  7.  
  8.         [NOT_NULL] public string name { get; set; }
  9.         [NOT_NULL] public string password { get; set; }
  10.  
  11.         public float x { get; set; }
  12.         public float y { get; set; }
  13.         public float z { get; set; }
  14.  
  15.         public override void Initialize(int id)
  16.         {
  17.             MySqlDataReader reader;
  18.             reader = GetReader("SELECT * FROM `" + GetType().Name + "` WHERE id = " + id);
  19.  
  20.             while (reader.Read())
  21.             {
  22.                 this.id = (int)reader["id"];
  23.  
  24.                 this.name = (string)reader["name"];
  25.                 this.x = (float)reader["x"];
  26.                 this.y = (float)reader["y"];
  27.                 this.z = (float)reader["z"];
  28.             }
  29.  
  30.             reader.Close();
  31.         }
  32.         public override void Insert()
  33.         {
  34.             Database.Insert(this, name, x, y, z);
  35.         }
  36.         public override void Update()
  37.         {
  38.             Database.Update(this, id, name, x, y, z);
  39.         }
  40.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement