diff options
| author | root | 2014-02-25 19:00:23 +0100 |
|---|---|---|
| committer | root | 2014-02-25 19:00:23 +0100 |
| commit | 8f54d6bfe9c35cae2efe8d1850b02c51e3cae69d (patch) | |
| tree | bb9500911881dd44ec4db26a78acc3d1300c6e60 /www/insertfile.php | |
| parent | 9740b868aa482580388a08956dd4db16e1673f61 (diff) | |
| parent | 4baee1f0a462bf9d3a7210f4c1ca44ca9c705da9 (diff) | |
| download | random-8f54d6bfe9c35cae2efe8d1850b02c51e3cae69d.tar.gz | |
database dir
Diffstat (limited to 'www/insertfile.php')
| -rw-r--r-- | www/insertfile.php | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/www/insertfile.php b/www/insertfile.php index a8b000c..5e07130 100644 --- a/www/insertfile.php +++ b/www/insertfile.php @@ -1,19 +1,31 @@ <? -$en_dic = "../blob/en_GB.dic"; -$test = "../blob/test"; +$dic = "../blob/en_GB.dic"; +$table = "english"; -//if($file = file($en_dic)){ -$file = file($test); - echo "Inserted file <br>"; - echo count($file); - echo "<br> " . $file . "<br>"; +$bool = false; - for($i=0;$i<count($file);$i++){ - echo $file[$i]; +$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."; } -/*} else { +} else { echo "No file found!"; } -*/ |
