blob: fd2c04047379501197edc3a98f026163517b515f [file] [log] [blame]
<?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'];
$_ID = $_GET['id'];
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->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 = 221560";
$sql_info2 = "SELECT bugs.bug_id, bugs.short_desc FROM milestones, products, bugs
WHERE products.name = \"Tigerstripe\" AND products.id = milestones.product_id AND bugs.target_milestone = milestones.value";
$rs = mysql_query($sql_info, $dbh);
if(mysql_errno($dbh) > 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->disconnect();
exit;
}
while($myrow = mysql_fetch_assoc($rs)) {
// echo "Bug ID: " . $myrow['bug_id'] . " Description: " . $myrow['short_desc'] . " Reporter: " . $myrow['somedude'];
echo "Bug: " . $myrow['bug_id'] . " Name: " . $myrow['short_desc'] . "</br>";
}
// echo "ID: " . $foo[];
$dbc->disconnect();
$rs = null;
$dbh = null;
$dbc = null;
}
?>