| <?php |
| |
| require_once "/home/data/httpd/eclipse-php-classes/system/dbconnection_bugs_ro.class.php"; |
| require_once "bug.class.php"; |
| |
| //print "$Id: BugzillaConnection.class.php,v 1.43 2008/04/09 02:25:18 edillon Exp $"; |
| # A convenience class for Bugzilla a set of bugzilla queries |
| class BugzillaConnection { |
| |
| private $dbc, $dbh; |
| private $productId; |
| |
| public function __construct() { |
| $this->dbc = new DBConnectionBugs(); |
| $this->dbh = $this->dbc->connect(); |
| } |
| |
| public function getTigerstripeProductID() { |
| if ( !isset($this->productId) ) { |
| $sql_info = "SELECT id FROM products WHERE name = \"Tigerstripe\""; |
| |
| $rs = $this->runQuery($sql_info); |
| if ( isset($rs) ) { |
| while($myrow = mysql_fetch_assoc($rs)) { |
| $this->productId = $myrow['id']; |
| } |
| |
| $rs = null; |
| } |
| } |
| return $this->productId; |
| } |
| |
| private function runQuery( $sqlQuery ) { |
| $rs = mysql_query($sqlQuery, $this->dbh); |
| if(mysql_errno($this->dbh) > 0) { |
| echo "There was an error processing this request"; |
| return; |
| } |
| |
| return $rs; |
| } |
| |
| public function getAllFixedBugs() { |
| $result = array(); |
| |
| $sql_info = "SELECT bugs.bug_id, bugs.short_desc FROM bugs |
| WHERE bugs.product_id = " . $this->getTigerstripeProductID() . " AND bugs.resolution = \"FIXED\""; |
| $rs = $this->runQuery($sql_info); |
| if ( isset($rs) ) { |
| while($myrow = mysql_fetch_assoc($rs)) { |
| $result[] = new Bug($myrow['bug_id'], $myrow['short_desc']); |
| } |
| |
| $rs = null; |
| } |
| return $result; |
| } |
| |
| /** |
| * Returns an array of Bug objects that were FIXED between $startTimestamp and $endTimestamp |
| * |
| * @param String $startTimestamp |
| * @param String $endTimestamp |
| * @return array of Bug |
| */ |
| public function getAllFixedBugsBetween( $startTimestamp, $endTimestamp ) { |
| #MySql expects seconds in the timestamp... |
| if ( strlen($startTimestamp) == 12 ) { |
| $startTimestamp = $startTimestamp . "00"; |
| } |
| if ( strlen($endTimestamp) == 12 ) { |
| $endTimestamp = $endTimestamp . "59"; |
| } |
| |
| $result = array(); |
| |
| $sql_info = "SELECT DISTINCT bugs.bug_id, bugs.short_desc FROM bugs, bugs_activity WHERE |
| bugs.product_id = " . $this->getTigerstripeProductID() . " AND bugs.resolution = \"FIXED\" |
| AND bugs_activity.bug_id = bugs.bug_id AND bugs_activity.fieldid = 11 AND bugs_activity.added = \"FIXED\" |
| AND bugs_activity.bug_when <= " . $endTimestamp . " AND bugs_activity.bug_when > " . $startTimestamp; |
| |
| $rs = $this->runQuery($sql_info); |
| if ( isset($rs) ) { |
| while($myrow = mysql_fetch_assoc($rs)) { |
| // echo $myrow['bug_id'] . "</br>"; |
| $result[] = new Bug( $myrow['bug_id'], $myrow['short_desc']); |
| } |
| |
| $rs = null; |
| } |
| return $result; |
| |
| } |
| |
| /** |
| * Returns an array of Bugs that were FIXED by the given Timestamp |
| * |
| * @param String $timestamp |
| * @return Array of Bug objects |
| */ |
| public function getAllFixedBugsBy( $timestamp ) { |
| return $this->getAllFixedBugsBetween( "20080101000000", $timestamp); |
| } |
| |
| public function __destruct() { |
| $this->dbc->disconnect(); |
| $this->dbh = null; |
| $this->dbc = null; |
| } |
| } |
| ?> |