summaryrefslogtreecommitdiff
path: root/www/setup.php
diff options
context:
space:
mode:
authorroot2014-02-25 19:00:23 +0100
committerroot2014-02-25 19:00:23 +0100
commit8f54d6bfe9c35cae2efe8d1850b02c51e3cae69d (patch)
treebb9500911881dd44ec4db26a78acc3d1300c6e60 /www/setup.php
parent9740b868aa482580388a08956dd4db16e1673f61 (diff)
parent4baee1f0a462bf9d3a7210f4c1ca44ca9c705da9 (diff)
downloadrandom-8f54d6bfe9c35cae2efe8d1850b02c51e3cae69d.tar.gz
database dir
Diffstat (limited to 'www/setup.php')
-rw-r--r--www/setup.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/www/setup.php b/www/setup.php
new file mode 100644
index 0000000..a4ab123
--- /dev/null
+++ b/www/setup.php
@@ -0,0 +1,34 @@
+<?
+
+$db = new SQLite3("../database/dict.db");
+
+foreach ($_GET as $name => $value) {
+ if(preg_match("/drop(ped)?/i",$name)){
+ $bool=true;
+ }
+}
+
+if($bool){
+ if($db->exec("
+ BEGIN TRANSACTION;
+ PRAGMA writable_schema = 1;
+ DELETE FROM sqlite_master WHERE type = 'table';
+ PRAGMA writable_schema = 0;
+ COMMIT;
+ VACUUM;")
+ ){
+ echo "dropped everything";
+ } else {
+ echo "error with database";
+ }
+} else {
+ if($db->exec("
+ BEGIN TRANSACTION;
+ CREATE TABLE IF NOT EXISTS english (id INTEGER PRIMARY KEY, word TEXT UIQUE);
+ COMMIT;")
+ ) {
+ echo "Success!";
+ } else {
+ echo "Failure!" ;
+ }
+}