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

chat.mod.php 704 B

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