summaryrefslogtreecommitdiff
path: root/blob/insertfile.php
blob: d098223bc1f8fd3fec9c4a1387b1de2e5ea8d2bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php

$dic = "en_GB.dic";
$table = "english";

//$dic = "../blob/wordlist_german.txt";
//$table = "german";

$bool = false;

$db = new SQLite3("db/dict.db");
//$db = new SQLite3("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!";
}