-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathvars.php
67 lines (49 loc) · 1.26 KB
/
vars.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
58
59
60
61
62
63
64
65
66
67
<?php
// parse vcap
if( getenv("VCAP_SERVICES") ) {
$json = getenv("VCAP_SERVICES");
}
# No DB credentials
else {
echo "No vcap services available.";
return;
}
# Decode JSON and gather DB Info
$services_json = json_decode($json,true);
$blu = $services_json["sqldb"];
if (empty($blu)) {
echo "No SQL database service instance is bound. Please bind a SQL database service instance";
return;
}
$bludb_config = $services_json["sqldb"][0]["credentials"];
// create DB connect string
$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=".
$bludb_config["db"].
";HOSTNAME=".
$bludb_config["host"].
";PORT=".
$bludb_config["port"].
";PROTOCOL=TCPIP;UID=".
$bludb_config["username"].
";PWD=".
$bludb_config["password"].
";";
// connect to BLUDB
$conn = db2_connect($conn_string, '', '');
if (!$conn) {
die("SQSLSTATE value: " . db2_conn_error());
}
// sql to create table
$sql = "select * from stock";
$result = db2_exec($conn, $sql, array('cursor' => DB2_SCROLLABLE));
if ($result) {
// print "select ok";
}
while($row = db2_fetch_object($result))
{
$items[] = clone $row;
}
db2_free_result($result);
db2_close($conn);
$site_title="My Cool Store";
?>