diff options
Diffstat (limited to 'blob/insertfile.php')
| -rw-r--r-- | blob/insertfile.php | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/blob/insertfile.php b/blob/insertfile.php new file mode 100644 index 0000000..8053eb5 --- /dev/null +++ b/blob/insertfile.php @@ -0,0 +1,37 @@ +<? + +$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++){ + + $file[$i] = preg_replace("/\/(.*)$/", "", $file[$i]); +// echo "#" . $i . ": " . $file[$i] . "<br>"; + + 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."; + } + +} else { + echo "No file found!"; +} |
