refactored some code, started creating groups
This commit is contained in:
@@ -21,16 +21,26 @@ class Handler
|
||||
{
|
||||
$this->pdo = new PDO('sqlite:' . __DIR__ . '/../../storage/database.sqlite');
|
||||
$this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
}
|
||||
|
||||
public function init(): void
|
||||
{
|
||||
$this->pdo->exec("
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
username VARCHAR(32) NOT NULL UNIQUE,
|
||||
password CHAR(255) NOT NULL
|
||||
)
|
||||
");
|
||||
$this->pdo->exec("
|
||||
CREATE TABLE IF NOT EXISTS chat_groups (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name VARCHAR(64) NOT NULL UNIQUE
|
||||
)
|
||||
");
|
||||
$this->pdo->exec("
|
||||
CREATE TABLE IF NOT EXISTS group_members (
|
||||
group_id INTEGER NOT NULL,
|
||||
username VARCHAR(32) NOT NULL,
|
||||
PRIMARY KEY (group_id, username),
|
||||
FOREIGN KEY (username) REFERENCES users(username)
|
||||
)
|
||||
");
|
||||
}
|
||||
|
||||
public function addUser(string $username, string $password): void
|
||||
|
||||
Reference in New Issue
Block a user