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

41 lines
682 B

  1. <?php
  2. class
  3. Chat
  4. {
  5. private $db;
  6. function
  7. __construct ()
  8. {
  9. $config = include ('./config.php');
  10. $db_host = $config['host'];
  11. $db_port = $config['port'];
  12. $db_user = $config['user'];
  13. $db_pass = $config['pass'];
  14. $this -> db = new mysqli ($db_host, $db_user, $db_pass, 'goatoh_training',
  15. $db_port);
  16. }
  17. function
  18. send (
  19. int $user_id,
  20. string $text):
  21. void
  22. {
  23. $sql = "
  24. INSERT INTO
  25. chats (
  26. user_id,
  27. text)
  28. VALUES
  29. (
  30. $user_id,
  31. '$text')";
  32. $this -> db -> query ($sql) or die ("db_insert error $sql");
  33. }
  34. }