-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreateItemIdCheck.php
48 lines (38 loc) · 1.47 KB
/
createItemIdCheck.php
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
<?php
if (php_sapi_name() != "cli") die("Can only be run from command line!");
require("/home/uesp/secrets/esolog.secrets");
$db = new mysqli($uespEsoLogWriteDBHost, $uespEsoLogWriteUser, $uespEsoLogWritePW, $uespEsoLogDatabase);
if ($db->connect_error) exit("Could not connect to mysql database!");
$query = "CREATE TABLE IF NOT EXISTS itemIdCheck(
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
itemId INTEGER NOT NULL,
version TINYTEXT NOT NULL,
INDEX index_itemId (itemId),
INDEX index_version (version(8))
) ENGINE=MYISAM;";
$result = $db->query($query);
if (!$result) exit("ERROR: Database query error creating table!\n" . $db->error);
$TABLEPREFIX = "";
$VERSION = "12";
$FIRSTID = 1;
$LASTID = 130000;
for ($id = $FIRSTID; $id <= $LASTID; $id++)
{
if ($id % 1000 == 0) print("Checking Item $id...\n");
$query = "SELECT itemId FROM minedItemSummary$TABLEPREFIX WHERE itemId=$id LIMIT 1;";
$result = $db->query($query);
if (!$result) exit("ERROR: Database query error (finding item)!\n" . $db->error);
$itemData = $result->fetch_assoc();
if (!$itemData)
{
$query = "DELETE FROM itemIdCheck WHERE itemId=" . $id . " AND version='". $VERSION ."';";
$result = $db->query($query);
}
else
{
$query = "INSERT INTO itemIdCheck(itemId, version) VALUES(" . $id . ", '". $VERSION ."');";
$result = $db->query($query);
if (!$result) exit("ERROR: Database query error (writing itemIdCheck)!\n" . $db->error);
}
}
?>