Advertisement
Guest User

Fix the sort by upvoted-downvoted-commented

a guest
Jun 17th, 2014
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.57 KB | None | 0 0
  1. from line 185
  2. if($this->searchTerm == "" && $this->url == ""){
  3.             // like when on the index or new pages.
  4.             $this->sql = "SELECT link_id, link_votes, link_karma, link_comments $from_where $search_clause GROUP BY link_id $this->orderBy LIMIT $this->offset, $limit";
  5.         } else if($this->searchTerm == 'upvoted'){
  6.        
  7.             $usrclause = "";
  8.             $group = "GROUP BY link_id";
  9.             if($catId) {
  10.              $this->sql = "SELECT DISTINCT * FROM " . table_links . ", " . table_votes . " WHERE ".$usrclause." vote_link_id=link_id AND vote_value > 0  AND (link_status='published' OR link_status='new') AND link_category=$catId ".$group." ORDER BY link_votes DESC LIMIT $this->offset, $limit"; //link_date
  11.             }else{
  12.                 $this->sql = "SELECT DISTINCT * FROM " . table_links . ", " . table_votes . " WHERE ".$usrclause." vote_link_id=link_id AND vote_value > 0  AND (link_status='published' OR link_status='new') ".$group." ORDER BY link_votes DESC LIMIT $this->offset, $limit"; //link_date
  13.             }
  14.         } else if($this->searchTerm == 'downvoted'){
  15.        
  16.             $usrclause = "";
  17.             $group = "GROUP BY link_id";
  18.             if($catId) {
  19.             $this->sql = "SELECT DISTINCT * FROM " . table_links . ", " . table_votes . " WHERE ".$usrclause." vote_link_id=link_id AND vote_value < 0  AND (link_status='published' OR link_status='new') AND link_category=$catId ".$group." ORDER BY link_votes ASC LIMIT $this->offset, $limit"; //link_date
  20.             }else{
  21.             $this->sql = "SELECT DISTINCT * FROM " . table_links . ", " . table_votes . " WHERE ".$usrclause." vote_link_id=link_id AND vote_value < 0  AND (link_status='published' OR link_status='new') ".$group." ORDER BY link_votes ASC LIMIT $this->offset, $limit"; //link_date
  22.             }
  23.          
  24.         } else if($this->searchTerm == "commented"){
  25.        
  26.             $usrclause = "";
  27.             $group = "GROUP BY link_id";
  28.             if($catId) {
  29.             $this->sql = "SELECT DISTINCT * FROM " . table_links . ", " . table_comments . " WHERE comment_status='published' ".$usrclause." AND comment_link_id=link_id AND (link_status='published' OR link_status='new') AND link_category=$catId ".$group." ORDER BY link_comments DESC LIMIT $this->offset, $limit";
  30.             }else{
  31.             $this->sql = "SELECT DISTINCT * FROM " . table_links . ", " . table_comments . " WHERE comment_status='published' ".$usrclause." AND comment_link_id=link_id AND (link_status='published' OR link_status='new') ".$group." ORDER BY link_comments DESC LIMIT $this->offset, $limit";
  32.             }
  33.         }
  34.         else{
  35.             $this->sql = "SELECT link_id, link_date, link_published_date, link_votes, link_karma, link_comments $from_where $search_clause {$this->orderBy}";
  36.         }
  37.        
  38.         ###### START Advanced Search ######
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement