add ts to links table

This commit is contained in:
Tomáš Mládek 2022-07-06 20:19:38 +02:00
parent bbf3da45e6
commit 5023235a2a

View file

@ -9,7 +9,8 @@ if (!$exists) {
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
url TEXT NOT NULL,
audio BOOLEAN NOT NULL CHECK (audio IN (0, 1)),
video BOOLEAN NOT NULL CHECK (video IN (0, 1))
video BOOLEAN NOT NULL CHECK (video IN (0, 1)),
ts NUMBER
);
EOD);
}
@ -22,10 +23,11 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
$video = $data->video;
if ($url !== null && $audio !== null && $video !== null) {
$stmt = $db->prepare('INSERT INTO links (url, audio, video) VALUES (:url, :audio, :video);');
$stmt = $db->prepare('INSERT INTO links (url, audio, video, ts) VALUES (:url, :audio, :video, :ts);');
$stmt->bindValue(':url', $url);
$stmt->bindValue(':audio', $audio);
$stmt->bindValue(':video', $video);
$stmt->bindValue(':ts', time());
$result = $stmt->execute();
if (!$result) {
http_response_code(500);