すくすくゴートうちゃんのサーヴァ(黒歴史)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

user.mod.php 1.1 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. class
  3. User
  4. {
  5. public int $id;
  6. public string $name;
  7. public string $pass;
  8. public string $inheritance_code;
  9. public static function
  10. find (
  11. int $id):
  12. Self
  13. {
  14. $sql = "
  15. SELECT
  16. *
  17. FROM
  18. users
  19. WHERE
  20. id = $id";
  21. $result = $GLOBALS['__db_connection'] -> query ($sql)
  22. or die ("db_select error $sql");
  23. $row = $result -> fetch_array ();
  24. $self = new Self;
  25. $self -> id = $id;
  26. $self -> name = $row['name'];
  27. $self -> pass = $row['pass'];
  28. $self -> inheritance_code = $row['inheritance_code'];
  29. return $self;
  30. }
  31. public function
  32. insert ():
  33. Self
  34. {
  35. $sql = "
  36. INSERT INTO
  37. users (
  38. name,
  39. pass,
  40. inheritance_code,
  41. created_at,
  42. modified_at)
  43. VALUES
  44. ('{$this -> name}',
  45. '{$this -> pass}',
  46. '{$this -> inheritance_code}',
  47. NOW(),
  48. NOW())";
  49. $GLOBALS['__db_connection'] -> query ($sql)
  50. or die ("db_insert error $sql");
  51. $this -> id = $GLOBALS['__db_connection'] -> insert_id;
  52. return $this;
  53. }
  54. }