From df32c63a6e9666eb062f806262aa23ed43c6eb99 Mon Sep 17 00:00:00 2001 From: Alexander Schmidt Date: Wed, 6 Feb 2013 09:55:20 +0100 Subject: [PATCH] moved db to admin area and dbscheme to seperate unique file. --- admin/include/db.inc | 13 +------------ admin/include/dbscheme.inc | 1 + include/db.inc | 15 ++------------- include/dbscheme.inc | 14 ++++++++++++++ 4 files changed, 18 insertions(+), 25 deletions(-) create mode 120000 admin/include/dbscheme.inc create mode 100644 include/dbscheme.inc diff --git a/admin/include/db.inc b/admin/include/db.inc index 7c4da1d..f7c4e6c 100644 --- a/admin/include/db.inc +++ b/admin/include/db.inc @@ -1,18 +1,7 @@ query('CREATE TABLE IF NOT EXISTS students - (mnumber int, firstname string, lastname string, email string, password string, blackboard int DEFAULT 0, lastblackboard TIMESTAMP, PRIMARY KEY (mnumber))'); - $db->query('CREATE TABLE IF NOT EXISTS workdone - (mnumber int, session int, manydone int, thisdone string, tstamp TIMESTAMP)'); - $db->query('CREATE TABLE IF NOT EXISTS prefs - (key string, value string, PRIMARY KEY (key))'); - $db->query('CREATE TABLE IF NOT EXISTS sessions - (id int NOT NULL, examples string, nexamples int, PRIMARY KEY (id))'); - $db->query('CREATE TABLE IF NOT EXISTS exams - (id int NOT NULL, score string, PRIMARY KEY (id))'); - $db->query('CREATE TABLE IF NOT EXISTS examscore - (mnumber int, exam int, scorestr string, tstamp TIMESTAMP)'); + require 'dbscheme.inc'; } } ?> diff --git a/admin/include/dbscheme.inc b/admin/include/dbscheme.inc new file mode 120000 index 0000000..e7bfda0 --- /dev/null +++ b/admin/include/dbscheme.inc @@ -0,0 +1 @@ +../../include/dbscheme.inc \ No newline at end of file diff --git a/include/db.inc b/include/db.inc index efd7aae..f3d1804 100644 --- a/include/db.inc +++ b/include/db.inc @@ -1,18 +1,7 @@ query('CREATE TABLE IF NOT EXISTS students - (mnumber int, firstname string, lastname string, email string, password string, blackboard int DEFAULT 0, lastblackboard TIMESTAMP, PRIMARY KEY (mnumber))'); - $db->query('CREATE TABLE IF NOT EXISTS workdone - (mnumber int, session int, manydone int, thisdone string, tstamp TIMESTAMP)'); - $db->query('CREATE TABLE IF NOT EXISTS prefs - (key string, value string, PRIMARY KEY (key))'); - $db->query('CREATE TABLE IF NOT EXISTS sessions - (id int NOT NULL, examples string, nexamples int, PRIMARY KEY (id))'); - $db->query('CREATE TABLE IF NOT EXISTS exams - (id int NOT NULL, score string, PRIMARY KEY (id))'); - $db->query('CREATE TABLE IF NOT EXISTS examscore - (mnumber int, exam int, scorestr string, tstamp TIMESTAMP)'); + if ($db = new PDO('sqlite:admin/banane.db')) { + require 'dbscheme.inc'; } } ?> diff --git a/include/dbscheme.inc b/include/dbscheme.inc new file mode 100644 index 0000000..02feb33 --- /dev/null +++ b/include/dbscheme.inc @@ -0,0 +1,14 @@ +query('CREATE TABLE IF NOT EXISTS students + (mnumber int, firstname string, lastname string, email string, password string, blackboard int DEFAULT 0, lastblackboard TIMESTAMP, PRIMARY KEY (mnumber))'); +$db->query('CREATE TABLE IF NOT EXISTS workdone + (mnumber int, session int, manydone int, thisdone string, tstamp TIMESTAMP)'); +$db->query('CREATE TABLE IF NOT EXISTS prefs + (key string, value string, PRIMARY KEY (key))'); +$db->query('CREATE TABLE IF NOT EXISTS sessions + (id int NOT NULL, examples string, nexamples int, PRIMARY KEY (id))'); +$db->query('CREATE TABLE IF NOT EXISTS exams + (id int NOT NULL, score string, PRIMARY KEY (id))'); +$db->query('CREATE TABLE IF NOT EXISTS examscore + (mnumber int, exam int, scorestr string, tstamp TIMESTAMP)'); +?> \ No newline at end of file -- 2.39.2