|
123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
-
- class
- Chat
- {
- private $db;
-
- private $id;
- var $user_id;
- var $pass;
-
- function
- __construct ()
- {
- $config = include ('./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
- insert ():
- void
- {
- $sql = "
- INSERT INTO
- chats (
- user_id,
- text)
- VALUES
- (
- {$this -> user_id},
- '{$this -> text}')";
- $this -> db -> query ($sql) or die ("db_insert error $sql");
- }
- }
-
|