php-guestbook/persistence.php

16 lines
349 B
PHP
Raw Normal View History

2021-12-10 20:22:06 +00:00
<?php
createDB();
function createDB()
{
$db = new SQLite3('guestbook.db');
$db->exec("CREATE TABLE user
(id_user INTEGER PRIMARY KEY, username TEXT NOT NULL UNIQUE, password TEXT)");
$db->exec("CREATE TABLE message
(id_msg INTEGER PRIMARY KEY, id_user INT, content TEXT NOT NULL,
FOREIGN KEY (id_user) REFERENCES user (id_user))");
}