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

51 lines
842 B

  1. <?php
  2. class
  3. User
  4. {
  5. private $db;
  6. private $id;
  7. var $name;
  8. var $pass;
  9. function
  10. __construct ()
  11. {
  12. $config = include ('./config.php');
  13. $db_host = $config['host'];
  14. $db_port = $config['port'];
  15. $db_user = $config['user'];
  16. $db_pass = $config['pass'];
  17. $this -> db = new mysqli ($db_host, $db_user, $db_pass, 'goatoh_training',
  18. $db_port);
  19. }
  20. public static function
  21. find (
  22. int $id):
  23. Self
  24. {
  25. $sql = "
  26. SELECT
  27. *
  28. FROM
  29. user
  30. WHERE
  31. id = $id";
  32. $result = $this -> db -> query ($sql) or die ("db_select error $sql");
  33. $row = $this -> db -> fetch_array ($result);
  34. $self = new Self;
  35. $self -> id = $id;
  36. $self -> name = $row['name'];
  37. $self -> pass = $row['pass'];
  38. return $self;
  39. }
  40. }