-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfetch_job.php
37 lines (35 loc) · 1.18 KB
/
fetch_job.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
<?php
header('Content-Type: text/xml; charset=utf-8');
/*------------------------------------------------------------------------*
* © 2010 University of Limerick. All rights reserved. This material may *
* not be reproduced, displayed, modified or distributed without the *
* express prior written permission of the copyright holder. *
*------------------------------------------------------------------------*/
require_once('./conf.php');
function fetchJob($com)
{
$fileData='';
try
{
//open the database
$db = new PDO('sqlite:'.BASE_DB_URL.'locTemp.sqlite');
$result = $db->query('SELECT Job FROM Demo where com="'.$com.'" and Status="pending"');
foreach($result as $row)
{
$fileData=$fileData.'<job>'.$row['Job'].'</job>';
}
$fileData="<jobs>".$fileData."</jobs>";
// close the database connection
$db = NULL;
}
catch(PDOException $e)
{
//print 'Exception : '.$e->getMessage();
$fileData="<error><msg>".$e->getMessage()."</msg></error>";
}
if (trim($fileData)=='<jobs></jobs>') $fileData="<error><msg>Component:".$com." does not have any pending jobs</msg></error>";
return $fileData;
}
$com=$_GET["com"];
echo fetchJob($com);
;?>