php-guestbook/persistence.php

16 lines
349 B
PHP

<?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))");
}