-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
63f5f35
commit 7b3f874
Showing
7 changed files
with
71 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,46 @@ | ||
|
||
-- phpMyAdmin SQL Dump | ||
-- version 4.4.10 | ||
-- http://www.phpmyadmin.net | ||
-- version 5.1.0 | ||
-- https://www.phpmyadmin.net/ | ||
-- | ||
-- Host: localhost:3306 | ||
-- Generation Time: Sep 18, 2016 at 03:50 PM | ||
-- Server version: 5.5.42 | ||
-- PHP Version: 7.0.0 | ||
-- Host: db | ||
-- Gegenereerd op: 27 apr 2021 om 17:26 | ||
-- Serverversie: 10.3.28-MariaDB-1:10.3.28+maria~focal | ||
-- PHP-versie: 7.4.16 | ||
|
||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; | ||
START TRANSACTION; | ||
SET time_zone = "+00:00"; | ||
|
||
|
||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; | ||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; | ||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; | ||
/*!40101 SET NAMES utf8mb4 */; | ||
|
||
-- | ||
-- Database: `socket_chat` | ||
-- | ||
CREATE DATABASE IF NOT EXISTS `socket_chat` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci; | ||
USE `socket_chat`; | ||
|
||
-- -------------------------------------------------------- | ||
|
||
-- | ||
-- Table structure for table `chat_interactions` | ||
-- Tabelstructuur voor tabel `chat_interactions` | ||
-- | ||
|
||
CREATE TABLE `chat_interactions` ( | ||
`message_id` int(11) NOT NULL, | ||
`to_id` varchar(255) NOT NULL, | ||
`from_id` varchar(255) NOT NULL, | ||
`message` text NOT NULL, | ||
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | ||
`ip_address` varchar(255) NOT NULL | ||
) ENGINE=InnoDB DEFAULT CHARSET=latin1; | ||
CREATE TABLE IF NOT EXISTS `chat_interactions` ( | ||
`message_id` int(11) NOT NULL AUTO_INCREMENT, | ||
`to_id` varchar(255) DEFAULT NULL, | ||
`from_id` varchar(255) NOT NULL, | ||
`message` text NOT NULL, | ||
`time` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), | ||
`ip_address` varchar(255) NOT NULL, | ||
PRIMARY KEY (`message_id`) | ||
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1; | ||
|
||
-- | ||
-- Indexes for dumped tables | ||
-- | ||
|
||
-- | ||
-- Indexes for table `chat_interactions` | ||
-- | ||
ALTER TABLE `chat_interactions` | ||
ADD PRIMARY KEY (`message_id`); | ||
|
||
-- | ||
-- AUTO_INCREMENT for dumped tables | ||
-- | ||
|
||
-- | ||
-- AUTO_INCREMENT for table `chat_interactions` | ||
-- | ||
ALTER TABLE `chat_interactions` | ||
MODIFY `message_id` int(11) NOT NULL AUTO_INCREMENT; | ||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; | ||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; | ||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,14 +4,14 @@ | |
* | ||
* The main configuration file for mysql_websocket_chat | ||
* | ||
* PHP version 7.2 | ||
* PHP version 7.2 and up. | ||
* | ||
* @category Configuration | ||
* @package Mysql_Websocket_Chat | ||
* @author Johnny Mast <[email protected]> | ||
* @license https://opensource.org/licenses/MIT MIT | ||
* @link https://github.com/johnnymast/mysql_websocket_chat | ||
* @since GIT:1.0 | ||
* @since 1.0 | ||
*/ | ||
|
||
/** | ||
|
@@ -24,22 +24,27 @@ | |
* @author Johnny Mast <[email protected]> | ||
* @license https://opensource.org/licenses/MIT MIT | ||
* @link https://github.com/johnnymast/mysql_websocket_chat | ||
* @since GIT:1.0 | ||
* @since 1.0 | ||
*/ | ||
class Database extends PDO | ||
class Database extends \PDO | ||
{ | ||
|
||
/** | ||
* Database constructor. | ||
* | ||
* @param string $username The username for the database | ||
* @param string $password The password for the database | ||
* @param string $host The hostname for the database | ||
* @param string $db The database name | ||
* @param string $username The username for the database | ||
* @param string $password The password for the database | ||
* @param string $host The hostname for the database | ||
* @param integer $port The port for the database | ||
* @param string $db The database name | ||
*/ | ||
public function __construct($username = '', $password = '', $host = '', $db = '') | ||
{ | ||
$dsn = 'mysql:dbname='.$db.';host='.$host; | ||
public function __construct($username = '', | ||
$password = '', | ||
$host = '', | ||
$port = 3306, | ||
$db = '' | ||
) { | ||
$dsn = 'mysql:dbname=' . $db . ';host=' . $host . ':' . $port; | ||
parent::__construct($dsn, $username, $password); | ||
} | ||
|
||
|
@@ -68,14 +73,13 @@ public function insert( | |
ip_address = :ip_address" | ||
); | ||
|
||
|
||
$statement->execute( | ||
[ | ||
'to_id' => $to_id, | ||
'from_id' => $from_id, | ||
'message' => $message, | ||
'ip_address' => $ip_address | ||
'to_id' => $to_id, | ||
'from_id' => $from_id, | ||
'message' => $message, | ||
'ip_address' => $ip_address | ||
] | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters