Changeset 594 for branches/stable/cgi-bin/search.cgi
- Timestamp:
- 05/15/13 16:17:00 (12 years ago)
- Location:
- branches/stable
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable
- Property svn:mergeinfo changed
/trunk merged: 518-548,552-553
- Property svn:mergeinfo changed
-
branches/stable/cgi-bin/search.cgi
r593 r594 146 146 my $cols = "cidr,custid,type,city,description"; 147 147 148 # hack fix for undefined variables 149 $webvar{custid} = '' if !$webvar{custid}; 150 $webvar{desc} = '' if !$webvar{desc}; 151 $webvar{notes} = '' if !$webvar{notes}; 152 $webvar{custexclude} = '' if !$webvar{custexclude}; 153 $webvar{descexclude} = '' if !$webvar{descexclude}; 154 $webvar{notesexclude} = '' if !$webvar{notesexclude}; 155 148 156 # First chunk of SQL. Filter on custid, description, and notes as necessary. 149 my $sql = "(select $cols from searchme where".150 " $webvar{custexclude} (custid ilike '%$webvar{custid}%'". 151 " $sqlconcat (select $cols from searchme where $webvar{descexclude} description ilike '%$webvar{desc}%')". 152 " $sqlconcat (select $cols from searchme where $webvar{notesexclude} notes ilike '%$webvar{notes}%')";157 my $sql = qq(SELECT $cols FROM searchme\n); 158 $sql .= " WHERE $webvar{custexclude} (custid ~ '$webvar{custid}')\n"; 159 $sql .= " $sqlconcat (select $cols from searchme where $webvar{descexclude} description ~ '$webvar{desc}')\n"; 160 $sql .= " $sqlconcat (select $cols from searchme where $webvar{notesexclude} notes ~ '$webvar{notes}')"; 153 161 154 162 # If we're not supposed to search for all types, search for the selected types. 163 $webvar{alltypes} = '' if !$webvar{alltypes}; 164 $webvar{typeexclude} = '' if !$webvar{typeexclude}; 155 165 if ($webvar{alltypes} ne 'on') { 156 166 $sql .= " $sqlconcat (select $cols from searchme where $webvar{typeexclude} type in ("; … … 164 174 # If we're not supposed to search for all cities, search for the selected cities. 165 175 # This could be vastly improved with proper foreign keys in the database. 176 $webvar{allcities} = '' if !$webvar{allcities}; 177 $webvar{cityexclude} = '' if !$webvar{cityexclude}; 166 178 if ($webvar{allcities} ne 'on') { 167 179 $sql .= " $sqlconcat (select $cols from searchme where $webvar{cityexclude} city in ("; … … 315 327 # Creates appropriate SQL to run the search and display the results 316 328 # with queryResults() 317 sub viewBy ($$){329 sub viewBy { 318 330 my ($category,$query) = @_; 319 331 … … 445 457 # Display search queries based on the passed SQL. 446 458 # Takes SQL, page number (for multipage search results), and a total count. 447 sub queryResults ($$$){459 sub queryResults { 448 460 my ($sql, $pageNo, $rowCount) = @_; 449 461 my $offset = 0; … … 529 541 # Return count of rows to be returned in a "real" query 530 542 # with the passed SQL statement 531 sub countRows ($){543 sub countRows { 532 544 # Note that the "as foo" is required 533 545 my $sth = $ip_dbh->prepare("select count(*) from ($_[0]) as foo");
Note:
See TracChangeset
for help on using the changeset viewer.