Changeset 8464 for trunk/MagicSoft/Mars/datacenter/db/plotinclude.php
- Timestamp:
- 04/27/07 23:39:10 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/datacenter/db/plotinclude.php
r8421 r8464 41 41 } 42 42 43 function CheckQuery($query) 44 { 45 if (strpos($query, " WHERE ")==FALSE) 46 return " WHERE "; 47 else 48 return " AND "; 49 } 50 43 51 function GetQuery($tables, $joins, $set) 44 52 { … … 58 66 $_GET["primstop"]=""; 59 67 $primstop=$_GET["primstop"]; 60 if (empty($_GET[ $column."Start"]))61 $_GET[ $column."Start"]="";62 $start1=$_GET[ $column."Start"];63 if (empty($_GET[ $column."Stop"]))64 $_GET[ $column."Stop"]="";65 $stop1=$_GET[ $column."Stop"];68 if (empty($_GET["Start"])) 69 $_GET["Start"]=""; 70 $start1=$_GET["Start"]; 71 if (empty($_GET["Stop"])) 72 $_GET["Stop"]=""; 73 $stop1=$_GET["Stop"]; 66 74 67 75 $query="SELECT " . $table . "." . $primary . ", "; … … 76 84 $_GET[$primary."Col2"]=""; 77 85 $column2=$_GET[$primary."Col2"]; 78 if (empty($_GET[ $column2."Start2"]))79 $_GET[ $column2."Start2"]="";80 $start2=$_GET[ $column2."Start2"];81 if (empty($_GET[ $column2."Stop2"]))82 $_GET[ $column2."Stop2"]="";83 $stop2=$_GET[ $column2."Stop2"];86 if (empty($_GET["Start2"])) 87 $_GET["Start2"]=""; 88 $start2=$_GET["Start2"]; 89 if (empty($_GET["Stop2"])) 90 $_GET["Stop2"]=""; 91 $stop2=$_GET["Stop2"]; 84 92 85 93 if ($column2==$primary) … … 90 98 $query.=" FROM " . $table; 91 99 $query.=$joins[$primary]; 92 if (!empty($primstart) && !empty($primstop))93 $query.=" WHERE " . $table . "." . $primary . " BETWEEN " . $primstart . " AND " . $primstop;94 100 95 if (!empty($start1) && !empty($stop1)) 101 if (!empty($primstart)) 102 $query.= " WHERE " . $table . "." . $primary . " > " . $primstart; 103 104 if (!empty($primstop)) 105 $query.= CheckQuery($query) . $table . "." . $primary . " < " . $primstop; 106 107 if (!empty($start1)) 108 $query.= CheckQuery($query) . GetTable($table, $column) . " > " . $start1; 109 110 if (!empty($stop1)) 111 $query.= CheckQuery($query) . GetTable($table, $column) . " < " . $stop1; 112 113 if ($_GET["plot"]=="val") 96 114 { 97 if (strpos($query, " WHERE ")==FALSE) 98 $query.=" WHERE " . $column . " BETWEEN " . $start1 . " AND " . $stop1; 99 else 100 $query.=" AND " . $column . " BETWEEN " . $start1 . " AND " . $stop1; 101 } 115 if (!empty($start2)) 116 $query.= CheckQuery($query) . GetTable($table, $column2) . " > " . $start2; 102 117 103 if ($_GET["plot"]=="val" && !empty($start2) && !empty($stop2)) 104 { 105 if (strpos($query, " WHERE ")==FALSE) 106 $query.=" WHERE " . $column2 . " BETWEEN " . $start2 . " AND " . $stop2; 107 else 108 $query.=" AND " . $column2 . " BETWEEN " . $start2 . " AND " . $stop2; 118 if (!empty($stop2)) 119 $query.= CheckQuery($query) . GetTable($table, $column2) . " < " . $stop2; 109 120 } 110 121 111 122 if (!empty($set) && !empty($_GET[$set])) 112 { 113 if (strpos($query, " WHERE ")==FALSE) 114 $query .= " WHERE "; 115 else 116 $query.=" AND "; 117 $query.= $table . "." . $primary . " IN (" . str_replace(" ", ",", $_GET[$set]) . ") "; 118 } 123 $query.= CheckQuery($query) . $table . "." . $primary . " IN (" . str_replace(" ", ",", $_GET[$set]) . ") "; 124 125 if (empty($_GET[$primary."Col3"])) 126 $_GET[$primary."Col3"]=""; 127 $column3=$_GET[$primary."Col3"]; 128 if (empty($_GET["Start3"])) 129 $_GET["Start3"]=""; 130 $start3=$_GET["Start3"]; 131 if (empty($_GET["Stop3"])) 132 $_GET["Stop3"]=""; 133 $stop3=$_GET["Stop3"]; 134 135 if (!empty($start3)) 136 $query.= CheckQuery($query) . GetTable($table, $column3) . " > " . $start3; 137 138 if (!empty($stop3)) 139 $query.= CheckQuery($query) . GetTable($table, $column3) . " < " . $stop3; 140 141 if (empty($_GET[$primary."Col4"])) 142 $_GET[$primary."Col4"]=""; 143 $column4=$_GET[$primary."Col4"]; 144 if (empty($_GET["Start4"])) 145 $_GET["Start4"]=""; 146 $start4=$_GET["Start4"]; 147 if (empty($_GET["Stop4"])) 148 $_GET["Stop4"]=""; 149 $stop4=$_GET["Stop4"]; 150 151 if (!empty($start4)) 152 $query.= CheckQuery($query) . GetTable($table, $column4) . " > " . $start4; 153 154 if (!empty($stop4)) 155 $query.= CheckQuery($query) . GetTable($table, $column4) . " < " . $stop4; 119 156 120 157 return $query;
Note:
See TracChangeset
for help on using the changeset viewer.