Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Phoenix/Accessing Bugzilla Data

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!

    <?php
	#
	# 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 
        				BUG.bug_id, 
				        BUG.short_desc,
			        	USR.realname AS somedude
		        	FROM 
				bugs AS BUG
					INNER JOIN profiles AS USR ON USR.userid = BUG.reporter
				WHERE
					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'];
		}
	}
    ?>

Back to the top