-
Notifications
You must be signed in to change notification settings - Fork 0
/
quick-query.php
44 lines (37 loc) · 1.16 KB
/
quick-query.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
<?php
#
# quick_query.php - query a Voyager server, output as TSV or HTML table
#
# (c)2013 Kathryn Lybarger. CC-BY-SA
#
$db_host = 'HOST.hosted.exlibrisgroup.com'; # host
$db_port = '1521'; # port
$ro_login = 'XXXX'; # read-only login
$ro_passwd = 'XXXX'; # read-only password
$html_table = 1; # set to 0 for TSV output
$query = 'SELECT * FROM VERSIONS'; #query
#-----------you should not have to edit below this line--------------
$db = "(DESCRIPTION=(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = $db_host)(PORT = $db_port)))(CONNECT_DATA=(SID=VGER)))";
$conn = oci_connect($ro_login, $ro_passwd, $db);
$stid = oci_parse($conn, $query);
oci_execute($stid);
if ($html_table) {
# print HTML table
print "<table border='1'>\n";
while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
print "<tr>\n";
foreach ($row as $item) {
print " <td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : " ") . "</td>\n";
}
print "</tr>\n";
}
print "</table>\n";
} else {
# print TSV
while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
foreach ($row as $item) {
print "$item\t";
}
print "\n";
}
}