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

52 lines
861 B

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