Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Phoenix/Accessing Bugzilla Data"

Line 1: Line 1:
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!
+
You can access the Bugzilla database from within your PHP scripts by using the [http://wiki.eclipse.org/Using_Phoenix#Database_API 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!
  
 
<source lang="php">
 
<source lang="php">

Revision as of 10:44, 2 October 2008

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 = 12345";
 
               $result = $App->bugs_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