|
From: Benjamin C. <bc...@us...> - 2001-10-30 05:19:56
|
Update of /cvsroot/phpbt/phpbt
In directory usw-pr-cvs1:/tmp/cvs-serv17647
Modified Files:
include.php query.php
Log Message:
Make the limit queries PG friendly and break them up over multiple lines
Index: include.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/include.php,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -r1.67 -r1.68
--- include.php 2001/10/30 04:04:08 1.67
+++ include.php 2001/10/30 05:19:53 1.68
@@ -35,6 +35,19 @@
var $User = DB_USER;
var $Password = DB_PASSWORD;
var $Seg_Table = TBL_DB_SEQUENCE;
+
+ // Attempt to handle different limit syntax
+ function limit_query($q_string, $limit, $offset = 0) {
+ if ($offset) {
+ if (DB_TYPE == 'pgsql') {
+ $this->query("$q_string limit $limit offset $offset");
+ } else {
+ $this->query("$q_string limit $offset, $limit");
+ }
+ } else {
+ $this->query("$q_string limit $limit");
+ }
+ }
function grab($q_string = '') {
if ($q_string) $this->query($q_string);
Index: query.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/query.php,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- query.php 2001/10/30 03:57:43 1.34
+++ query.php 2001/10/30 05:19:54 1.35
@@ -27,7 +27,8 @@
function delete_saved_query($queryid) {
global $q, $u, $me;
- $q->query("delete from ".TBL_SAVED_QUERY." where user_id = $u and saved_query_id = $queryid");
+ $q->query("delete from ".TBL_SAVED_QUERY." where user_id = $u
+ and saved_query_id = $queryid");
header("Location: $me?op=query");
}
@@ -41,11 +42,13 @@
$t->set_block('savequeryblock','row','rows');
// Build the javascript-powered select boxes
- $q->query("select project_id, project_name from ".TBL_PROJECT." where active = 1 order by project_name");
+ $q->query("select project_id, project_name from ".TBL_PROJECT.
+ " where active = 1 order by project_name");
while (list($pid, $pname) = $q->grab()) {
// Version array
$js .= "versions['$pname'] = new Array(new Array('','All'),";
- $nq->query("select version_name, version_id from ".TBL_VERSION." where project_id = $pid and active");
+ $nq->query("select version_name, version_id from ".TBL_VERSION.
+ " where project_id = $pid and active");
while (list($version,$vid) = $nq->grab()) {
$js .= "new Array($vid,'$version'),";
}
@@ -54,7 +57,8 @@
// Component array
$js .= "components['$pname'] = new Array(new Array('','All'),";
- $nq->query("select component_name, component_id from ".TBL_COMPONENT." where project_id = $pid and active");
+ $nq->query("select component_name, component_id from ".TBL_COMPONENT.
+ " where project_id = $pid and active");
while (list($comp,$cid) = $nq->grab()) {
$js .= "new Array($cid,'$comp'),";
}
@@ -102,7 +106,8 @@
// Open bugs assigned to the user -- a hit list
if ($assignedto || $reportedby) {
- $q->query("select status_id from ".TBL_STATUS." where status_name ".($open ? '' : 'not ')."in ('Unconfirmed', 'New', 'Assigned', 'Reopened')");
+ $q->query("select status_id from ".TBL_STATUS." where status_name ".
+ ($open ? '' : 'not ')."in ('Unconfirmed', 'New', 'Assigned', 'Reopened')");
while ($statusid = $q->grab_field()) $status[] = $statusid;
$query[] = 'bug.status_id in ('.delimit_list(',',$status).')';
if ($assignedto) {
@@ -169,7 +174,8 @@
// Save the query if requested
if ($savedqueryname) {
$savedquerystring = ereg_replace('&savedqueryname=.*(&?)', '\\1', $GLOBALS['QUERY_STRING']);
- $q->query("insert into ".TBL_SAVED_QUERY." (saved_query_id, user_id, saved_query_name, saved_query_string)"
+ $q->query("insert into ".TBL_SAVED_QUERY.
+ " (saved_query_id, user_id, saved_query_name, saved_query_string)"
." values (".$q->nextid(TBL_SAVED_QUERY).", $u, '$savedqueryname', '$savedquerystring')");
}
if (!$order) {
@@ -195,7 +201,7 @@
'project' => build_select('project'),
'TITLE' => $TITLE['buglist']));
- $q->query("select bug.*, reporter.login as reporter, owner.login as owner,
+ $q->limit_query("select bug.*, reporter.login as reporter, owner.login as owner,
lastmodifier.login as lastmodifier, project_name, severity_name,
status_name, os_name, version_name, component_name, resolution_name, severity_color"
." from ".TBL_BUG." bug left join ".TBL_RESOLUTION." resolution using (resolution_id),"
@@ -208,7 +214,7 @@
." and bug.os_id = os.os_id and bug.version_id = version.version_id"
." and bug.component_id = component.component_id and bug.project_id = project.project_id "
. ($querystring != '' ? "and $querystring " : '')
- ." order by $order $sort limit $llimit, $selrange");
+ ." order by $order $sort", $selrange, $llimit);
$headers = array(
'bug_id' => 'bug_id',
|