Jump to: navigation, search

Phoenix/Accessing Bugzilla Data

< Phoenix
Revision as of 09:50, 2 October 2008 by Denis.roy.eclipse.org (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

You can access the Bugzilla database from within your PHP scripts by using the Database API. For data integrity reasons, this access is read-only. Please note that before using this code, you must register the URL of your PHP page with the eclipse.org webmaster, or it will not work!

	# Sample PHP code to issue a Bugzilla query.

	# :::::PLEASE NOTE:::::
	# The bugzilla database is very large, and some long-running queries can affect the performance
	# of bugs.eclipse.org
	# We suggest you don't use these queries in "publicly accessible" web pages, or if your queries
	# are for statistical/aggregation purposes, run them once a day and post the results of the query in a static web page.
	# Queries that run for more than 5 minutes are killed by the SQL server.

	# simplisticly silly way of preventing the page from being accessed by just anybody.
	# Linking to page.php?password=abc123 obviously defeats the whole purpose of this.
	$_PASSWORD = $_GET['password'];
	if($_PASSWORD == "abc123") {
		# Please note: some columns are not SELECTable, such as the password and e-mail address.
		# They will return an error.
		$sql_info = "SELECT 
			        	USR.realname AS somedude
				bugs AS BUG
					INNER JOIN profiles AS USR ON USR.userid = BUG.reporter
					BUG.bug_id = 181972";
               $result = $App->bugzilla_sql($sql_info);
               while($myrow = mysql_fetch_assoc($result)) {
                       echo "Bug ID: " . $myrow['bug_id'] . " Description: " . $myrow['short_desc'] . " Reporter: " . $myrow['somedude'];