FOSSology  4.4.0
Open Source License Compliance by Open Source Software
check4jobs.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2008 Hewlett-Packard Development Company, L.P.
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
27 require_once (TESTROOT . '/testClasses/db.php');
28 
29 define('SQL', "SELECT *
30  FROM jobqueue
31  INNER JOIN job ON jobqueue.jq_job_fk = job.job_pk
32  LEFT OUTER JOIN upload ON upload_pk = job.job_upload_fk
33  LEFT JOIN jobdepends ON jobqueue.jq_pk = jobdepends.jdep_jq_fk
34  WHERE (jobqueue.jq_starttime IS NULL OR jobqueue.jq_endtime IS
35  NULL OR jobqueue.jq_end_bits > 1)
36  ORDER BY upload_filename,upload.upload_pk,job.job_pk,jobqueue.jq_pk," .
37  "jobdepends.jdep_jq_fk;");
38 
39 class check4jobs {
40 
41  protected $jobCount=NULL;
42  private $Db;
43 
44  function __construct() {
45  /*
46  * always use the installed root user for the db.
47  */
48  if(file_exists('/etc/fossology/Db.conf')) {
49  $options = file_get_contents('/etc/fossology/Db.conf');
50  }
51  else if (file_exists('/usr/local/etc/fossology/Db.conf')) {
52  $options = file_get_contents('/usr/local/etc/fossology/Db.conf');
53  }
54  else {
55  return(FALSE);
56  }
57  $this->Db = new db($options);
58  $connection = $this->Db->connect();
59  if (!(is_resource($connection))) {
60  print "check4jobs:FATAL ERROR!, could not connect to the data-base\n";
61  return(FALSE);
62  }
63  $this->_ck4j();
64  return;
65  }
66 
67  public function Check() {
68  $this->_ck4j();
69  return($this->jobCount);
70  }
71  private function _ck4j() {
72  $results = $this->Db->dbQuery(SQL);
73  $howMany = count($results);
74  $this->jobCount = $howMany;
75  return;
76  }
77 
78  public function getJobCount() {
79  return($this->jobCount);
80  }
81 } // check4jobs
char SQL[256]
SQL query to execute.
Definition: adj2nest.c:78
Definition: db.php:28