|
12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
-
- class
- Chat
- {
- var $db;
-
- function
- __construct ()
- {
- $config = include (__DIR__ . '/config.php');
-
- $db_host = $config['host'];
- $db_port = $config['port'];
- $db_user = $config['user'];
- $db_pass = $config['pass'];
-
- $this -> db = new mysqli ($db_host, $db_user, $db_pass, 'goatoh_training',
- $db_port);
- }
-
- function
- send_chat (
- int $user_id,
- string $text):
- void
- {
- $sql = "
- INSERT INTO
- chats (
- id,
- text)
- VALUES
- (
- $user_id,
- '$text')";
- $this -> db -> query ($sql) or die ("db_insert error $sql");
- }
- }
-
|