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

Difference between revisions of "Phoenix/Accessing Bugzilla Data"

(New page: 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, ...)
 
 
(2 intermediate revisions by one other user not shown)
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">
 
     <?php
 
     <?php
 
#
 
#
Line 18: Line 19:
 
$_PASSWORD = $_GET['password'];
 
$_PASSWORD = $_GET['password'];
 
if($_PASSWORD == "abc123") {
 
if($_PASSWORD == "abc123") {
 
 
 
 
# Please note: some columns are not SELECTable, such as the password and e-mail address.
 
# Please note: some columns are not SELECTable, such as the password and e-mail address.
Line 30: Line 30:
 
INNER JOIN profiles AS USR ON USR.userid = BUG.reporter
 
INNER JOIN profiles AS USR ON USR.userid = BUG.reporter
 
WHERE
 
WHERE
BUG.bug_id = 12345";
+
BUG.bug_id = 181972";
 
 
               $result = $App->bugs_sql($sql_info);
+
               $result = $App->bugzilla_sql($sql_info);
               while($row = mysql_fetch_assoc($result)) {
+
               while($myrow = mysql_fetch_assoc($result)) {
 
                       echo "Bug ID: " . $myrow['bug_id'] . " Description: " . $myrow['short_desc'] . " Reporter: " . $myrow['somedude'];
 
                       echo "Bug ID: " . $myrow['bug_id'] . " Description: " . $myrow['short_desc'] . " Reporter: " . $myrow['somedude'];
 
}
 
}
 
}
 
}
 
     ?>
 
     ?>
 +
</source>

Latest revision as of 10:50, 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 = 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