-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWriteInsertQueries.php
More file actions
70 lines (53 loc) · 2.01 KB
/
WriteInsertQueries.php
File metadata and controls
70 lines (53 loc) · 2.01 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
/**
* Created by PhpStorm.
* User: starstryder
* Date: 5/15/19
* Time: 2:43 PM
*/
// Step 0: Read settings file
require_once("WriteInsertQueries_settings.php");
// Step 1: Open files
$imagesets = fopen($file_imagesets, 'r') or die("Cannot open " . $file_imagesets);
$output = fopen($file_queries, 'w') or die("Cannot open " . $file_queries);
while (!feof($imagesets)) {
$image = fgets($imagesets);
if (strlen($image) > 5) {
$extension = substr($image, -5, -1);
$image = substr($image, 0, -5);
// Create the Image Set Insert - RUN THIS ALONE FOR NOW, THEN COMMENT OUT
// $query = "INSERT INTO image_sets (name, application_id) VALUES ('" . $image . $extension . "', 21);\r\n ";
// fwrite($output, $query);
// Step 2: Get offsets
// Step 2a: enter offset amount
if (!strcmp($offset_type, "offset")) {
echo "Regular offsets in use. \n";
}
// OR
// Step 2b: enter manual offsets
elseif (!strcmp($offset_type, "manual")) {
echo "manual offsets in use. \n";
$x_arraysize = sizeof($x_array);
$y_arraysize = sizeof($y_array);
$cnt = 0;
for ($i = 0; $i < $x_arraysize; $i++) {
for ($j = 0; $j < $y_arraysize; $j++) {
$x = $x_array[$i];
$y = $y_array[$j];
$cnt++;
$query = "INSERT INTO images (image_set_id, application_id, name, file_location, premarked, done, details) ";
$query .= "VALUES (" . $set_id . ", 21, '" . $image . "_" . $cnt . "', '" . $path_choppedImages . $image . "_" . $cnt . $extension . "', 0, 0, '{\"x\":$x, \"y\":$y}');\r\n";
fwrite($output, $query);
}
}
} else {
die("Valid offset type not given.");
}
$set_id++;
}
}
// Step 4: generate queries
// Step 4a: Generate image sets
// AND
// Step 4b: Generate images
?>