すくすくゴートうちゃんのサーヴァ(黒歴史)
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.
 
 
 

62 lines
1.1 KiB

  1. <?php
  2. class
  3. User
  4. {
  5. var $id;
  6. var $name;
  7. var $pass;
  8. var $inheritance_code;
  9. public static function
  10. find (
  11. int $id):
  12. Self
  13. {
  14. $sql = "
  15. SELECT
  16. *
  17. FROM
  18. user
  19. WHERE
  20. id = $id";
  21. $result = $GLOBALS['__db_connection'] -> query ($sql)
  22. or die ("db_select error $sql");
  23. $row = $this -> db -> fetch_array ($result);
  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. VALUES
  43. ('{$this -> name}',
  44. '{$this -> pass}',
  45. '{$this -> inheritance_code}',
  46. NOW())";
  47. $GLOBALS['__db_connection'] -> query ($sql)
  48. or die ("db_insert error $sql");
  49. $this -> id = $GLOBALS['__db_connection'] -> insert_id;
  50. return $this;
  51. }
  52. }