-
Notifications
You must be signed in to change notification settings - Fork 0
/
project_get_detail.php
82 lines (70 loc) · 2.19 KB
/
project_get_detail.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?PHP
/********************
Author:
Function:
*********************/
$projId = $_POST['ID'];
//$sportId = 4;
date_default_timezone_set('Australia/Sydney');
error_log("In project_get_detail.php...");
require_once("dbconnector.php");
//require_once("check_session.php");
/*
if (!checkSession()){
error_log("Session Time out.");
echo "error: Session has timed out. Please login again...";
return false;
}
*/
GetProjectDetail($projId);
function GetProjectDetail($projId){
//Return metadata about the columns in each table for a given database (table_schema)
$qry = "SELECT id, p_name, p_details FROM tb_projects where id = " . $projId;
date_default_timezone_set('Australia/Sydney');
error_log("In project_get_detail.php...\n" . $qry);
$dbConn = opendatabase();
$result = mysqli_query($dbConn, $qry);
date_default_timezone_set('Australia/Sydney');
error_log("Records in Projects: " . mysqli_num_rows($result));
if(!$result || mysqli_num_rows($result) <= 0){
echo("Could not obtain metadata information.");
return false;
}
/*****************************************************************/
$xml = new XMLWriter();
//$projXml = new DOMDocument();
//$xml->openURI("php://output");
$xml->openMemory();
$xml->startDocument();
$xml->setIndent(true);
$xml->startElement("projects");
while ($row = mysqli_fetch_assoc($result)) {
$xml->startElement("project");
$xml->writeAttribute('id', $projId);
$xml->writeRaw($row['p_name']);
$xml->endElement();
$xml->startElement("project_details");
$xml->startCData("details");
$xml->writeRaw($row['p_details']);
$xml->endCData();
$xml->endElement();
}
$xml->endElement();
$xml->endDocument();
$dbConn -> close();
header('Content-type: text/xml');
$strXML = $xml->outputMemory(TRUE);
$xml->flush();
date_default_timezone_set('Australia/Sydney');
error_log("String XML:\n " . $strXML);
//$projXml->loadXML($strXML);
echo $strXML;
/*****************************************************************
$options = array();
while ($row = mysqli_fetch_assoc($result)){
$options['object_row'][] = $row;
}
echo json_encode($options);
*****************************************************************/
}
?>