Fix extra comma in cross-table sql

This commit is contained in:
Miles Lott 2001-02-22 15:05:48 +00:00
parent 27c6cfa741
commit 5c9b01628c

View File

@ -370,11 +370,11 @@
while(list($name,$value)=each($stock_fields)) { while(list($name,$value)=each($stock_fields)) {
$std .= "a.".$name.","; $std .= "a.".$name.",";
} }
$std = substr($std,0,-1); //$std = substr($std,0,-1);
while(list($name,$value)=each($extra_fields)) { while(list($name,$value)=each($extra_fields)) {
$ext .= "b.".$name.","; $ext .= "b.".$name.",";
} }
$ext = substr($ext,0,-1); //$ext = substr($ext,0,-1);
if (!empty($fieldlist2)) { if (!empty($fieldlist2)) {
$filtertemp = " AND " . $filterlist2 . " "; $filtertemp = " AND " . $filterlist2 . " ";
} }
@ -382,7 +382,10 @@
if ($DEBUG && $filtertemp) { if ($DEBUG && $filtertemp) {
echo "<br>DEBUG - Filtering with: #" . $filtertemp . "#"; echo "<br>DEBUG - Filtering with: #" . $filtertemp . "#";
} }
$qfields = $std . $ext;
$qfields = substr($qfields,0,-1);
if ($query) { if ($query) {
$squery = " AND (n_family like '%$query%' OR n_middle like '" $squery = " AND (n_family like '%$query%' OR n_middle like '"
. "%$query%' OR n_given like '%$query%' OR d_email like '%$query%' OR " . "%$query%' OR n_given like '%$query%' OR d_email like '%$query%' OR "
@ -392,8 +395,8 @@
. "org_name like '%$query%')"; . "org_name like '%$query%')";
} }
$sql = 'SELECT a.id,a.tid,a.lid,a.owner,b.id,'. $std . ',' $sql = 'SELECT a.id,a.tid,a.lid,a.owner,b.id,'
. $ext . ' FROM '.$this->std_table.' AS a, ' . $qfields . ' FROM '.$this->std_table.' AS a, '
. $tmp_table .' AS b WHERE a.id=b.id ' . $filtertemp . $tmp_table .' AS b WHERE a.id=b.id ' . $filtertemp
. $squery . $ordermethod; . $squery . $ordermethod;