blob: 8405c28ffd5bafe6a6ef801900a78ec7a0996630 [file]
<?php
#*****************************************************************************
#
# en_dbo_bugs.php
#
# Author: Denis Roy
# Date: 2005-06-16
#
# Description: Bugzilla Database Object
#
# HISTORY:
#
#****************************************************************************
include("../html/header.php");
$Menu = new Menu("en");
include("../modules/menu.php");
?>
<br />
<td width="100%" valign="top" class="normal">
<font class="large_title">Bugzilla database object</font><br /><br />
You can access the Bugzilla database from within your PHP scripts by using a Bugzilla Database Object.
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 <b>it will not work!</b><br />
<pre>
&lt;?php
#
# Sample PHP code to issue a Bugzilla query.
# Logic, DB and Presentation lumped here for simplicity.
#
#
# :::::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") {
# Load up the classfile
# You need to tell the WebMaster from which URL you are loading this class from,
# otherwise the connect() will fail.
require_once "/home/data/httpd/eclipse-php-classes/system/dbconnection_bugs_ro.class.php";
# Connect to database
$dbc = new DBConnectionBugs();
$dbh = $dbc-&gt;connect();
# 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";
$rs = mysql_query($sql_info, $dbh);
if(mysql_errno($dbh) &gt; 0) {
echo "There was an error processing this request";
# For debugging purposes - don't display this stuff in a production page.
# echo mysql_error($dbh);
# Mysql disconnects automatically, but I like my disconnects to be explicit.
$dbc-&gt;disconnect();
exit;
}
while($myrow = mysql_fetch_assoc($rs)) {
echo "Bug ID: " . $myrow['bug_id'] . " Description: " . $myrow['short_desc'] . " Reporter: " . $myrow['somedude'];
}
$dbc-&gt;disconnect();
$rs = null;
$dbh = null;
$dbc = null;
}
?&gt;
</pre>
</td>
<?php
include("../html/footer.php");
?>