From fd3233b5ca4de95c221d085858887db3a7d44665 Mon Sep 17 00:00:00 2001 From: sjaster Date: Wed, 31 May 2017 18:26:33 +0200 Subject: [PATCH] minor fixes on databes interaction --- libs/keyLib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/keyLib.php b/libs/keyLib.php index 98677b9..08ab932 100755 --- a/libs/keyLib.php +++ b/libs/keyLib.php @@ -59,7 +59,7 @@ $handle = new SQLite3($fileName); if (!$handle) return false; - $handle->exec("DROP TABLE answers;"); + $handle->exec("DROP TABLE IF EXISTS answers;"); $handle->exec("CREATE TABLE IF NOT EXISTS 'answers'(KeyId text primary key,Status text,Student int,Answer);"); $keys = GenerateKeys($keyAmount); $count = count($keys); @@ -216,7 +216,7 @@ return false; //secure deleting by checking if key has been uesed already - $stmt = $handle->prepare("DELETE FROM answers WHERE KeyId=:keyid;"); + $stmt = $handle->prepare("DELETE FROM answers WHERE KeyId=:keyid AND Answer IS NULL;"); if ($stmt) { $stmt->bindValue(':keyid', $key, SQLITE3_TEXT);