From: Alexander Schmidt Date: Wed, 6 Feb 2013 08:55:20 +0000 (+0100) Subject: moved db to admin area and dbscheme to seperate unique file. X-Git-Url: https://git.treefish.org/banana.git/commitdiff_plain/df32c63a6e9666eb062f806262aa23ed43c6eb99?hp=75c95fb6291c3baacfe1883b3f1207c2b34fd78c moved db to admin area and dbscheme to seperate unique file. --- 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