summaryrefslogtreecommitdiff
path: root/www/insertfile.php
diff options
context:
space:
mode:
authorHorus32014-02-25 18:57:34 +0100
committerHorus32014-02-25 18:57:34 +0100
commit4baee1f0a462bf9d3a7210f4c1ca44ca9c705da9 (patch)
tree0ff7128f3fd46004918d3d8cefd7d572e2938b8d /www/insertfile.php
parent0e7bf4852888e06ec2da9b83aabcc8b39475d15b (diff)
downloadrandom-4baee1f0a462bf9d3a7210f4c1ca44ca9c705da9.tar.gz
database setup
Diffstat (limited to 'www/insertfile.php')
-rw-r--r--www/insertfile.php29
1 files changed, 25 insertions, 4 deletions
diff --git a/www/insertfile.php b/www/insertfile.php
index cfc52a7..5e07130 100644
--- a/www/insertfile.php
+++ b/www/insertfile.php
@@ -1,10 +1,31 @@
<?
-$en_dic = "../blob/en_GB.dic";
-$test = "../blob/test";
+$dic = "../blob/en_GB.dic";
+$table = "english";
+
+$bool = false;
+
+$db = new SQLite3("../database/dict.db");
+
+if($file = file($dic)){
+
+ $rows = count($file);
+ for($i=0;$i<$rows;$i++){
+ if(!$db->exec("
+ BEGIN TRANSACTION;
+ INSERT INTO " . $table " VALUES (NULL, " . $file[$i] . ");
+ COMMIT;
+ ")){
+ echo "Failure writing to the database at row" . $i ."!";
+ $bool = true;
+ break;
+ }
+ }
+
+ if(!$bool){
+ echo "Successfull transfered the file into the database.";
+ }
-if($file = file($en_dic)){
- echo "Inserted file";
} else {
echo "No file found!";
}