-
Notifications
You must be signed in to change notification settings - Fork 0
/
atom_ead_update.php
57 lines (43 loc) · 1.5 KB
/
atom_ead_update.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
49
50
51
52
53
54
55
56
57
<?php
//turn off notices
//error_reporting(E_ALL ^ E_NOTICE);
include 'complete_atom_to_ckan_config.php';
//open new connection to mysql
$link = new mysqli("localhost", $mysql_user, $mysql_password, $mysql_database);
if ($link->connect_errno)
{
die('Could not connect: ' . $link->connect_errno);
}
$link->set_charset("utf8");
$sql = "select id from information_object where ((level_of_description_id>191 and level_of_description_id<199) or level_of_description_id=8190 or level_of_description_id is NULL and id<>1)";
$result = $link->query($sql);
$rows = array();
while($row = $result->fetch_assoc())
{
$rows[] = $row["id"];
}
$result->close();
foreach ($rows as $line)
{
$q2 = "select date from event_i18n join event on event.id=event_i18n.id where object_id=".$line.";";
$res2 = $link->query($q2);
while($row = $res2->fetch_assoc())
{
$date = $row["date"];
}
$res2->close();
if(!empty($date)){
if (strpos($date,"19")!== false) $term_id=13602;//ww1
else $term_id=13604;//mm
$sql="insert into object values ('QubitObjectTermRelation',NOW(),NOW(),NULL,0)";
$result = $link->query($sql);
$key=$link->insert_id;
$sql="insert into object_term_relation values(".$key.", ".$line.", ".$term_id.", null, null)";
$result = $link->query($sql);
$sql="update object set updated_at=NOW() where id=".$line;
$result = $link->query($sql);
}
unset($date);
}
echo "DONE";
?>