|
此次phpwin内核改写所以更新麻烦了些,不过总的来说,比原来要简洁一点~~
还是更新(只是因为原来的代码太长,查询次数太多-.-||)
[codes=php]
                        $query = $db->query("SELECT * FROM pw_threads WHERE $sql $searchadd ORDER BY $topadd $orderway $asc ".pwLimit($offset,$limit2));
            while ($thread = $db->fetch_array($query)) {
                $tpcdb[] = $thread;
                $lastdate[]=$thread['lastpost'];
            }
            $db->free_result($query);
            $isdeled=$db->query("select tid from pw_recycle");
            while($thread=$db->fetch_array($isdeled)){
                $del[]=$thread['tid'];
            }
            $db->free_result($isdeled);
            if(count($del)>=1){
                $dellist="and tid NOT IN (".implode(',',$del).")";
            }
            if(isset($tpcdb[$limit2-1])){
                if($offset>0){
                    $shadowsql="SELECT * FROM pw_threads WHERE shadow LIKE '%~".$fid."~%' $searchadd $dellist and lastpost>".$tpcdb[$limit2-1]['lastpost']." and lastpost<".$tpcdb[0]['lastpost']." ORDER BY $topadd $orderway $asc";
                }else{
                    $shadowsql="SELECT * FROM pw_threads WHERE shadow LIKE '%~".$fid."~%' $searchadd $dellist and lastpost>".$tpcdb[$limit2-1]['lastpost']." ORDER BY $topadd $orderway $asc";
                }
            }else{
                $shadowsql="SELECT * FROM pw_threads WHERE shadow LIKE '%~".$fid."~%' $searchadd $dellist ORDER BY $topadd $orderway $asc ".pwLimit($offset,$limit2-count($tpcdb));
            }
            $query = $db->query($shadowsql);
            while ($thread = $db->fetch_array($query)) {
                $tpcdb[] = $thread;
                $lastdate[]=$thread['lastpost'];
            }
            $db->free_result($query);
            array_multisort($lastdate,SORT_DESC,$tpcdb);
            $R && $tpcdb = array_reverse($tpcdb);
[/codes]
原始代码是
替换就是了
另外更新
①现在投影后的帖子不会一堆出现在精华贴分类里面了,除非它本来就是精华
②分类贴按照分类ID出现在对应的分类栏里,这个应该影响不大,建议将某些共用分类设置同ID(如:求助,演示等)
恩,我原来的那个号登陆不了了,所以就拿这号发了~~
[codes=php]
      $dellist='(';
      $isdeled=$db->query("select tid from pw_recycle");
      while($rt = $db->fetch_array($isdeled)){
        if($dellist=="("){
          $dellist.=$rt['tid'];
        }else{
          $dellist.=",".$rt['tid'];
        }
      }
      $dellist.=')';
      $db->free_result($isdeled);
      if($offset>0){
        $query = $db->get_one("SELECT * FROM pw_threads WHERE $sql $searchadd ORDER BY $topadd $orderway $asc ".pwLimit($offset,1));
        $stdt=$query['lastpost'];
        $db->free_result($query);
      }
      $query = $db->get_one("SELECT * FROM pw_threads WHERE $sql $searchadd ORDER BY $topadd $orderway $asc ".pwLimit($offset+$limit2,1));
      $ltdt=$query['lastpost'];
      $db->free_result($query);
      if($stdt && $ltdt){
        if($dellist=="()"){
          $shadow=$db->query("SELECT tid,shadow FROM pw_threads WHERE shadow LIKE '%~".$fid."~%' $searchadd and lastpost>=".min($stdt,$ltdt)." and lastpost<=".max($stdt,$ltdt));
        }else{
          $shadow=$db->query("SELECT tid,shadow FROM pw_threads WHERE shadow LIKE '%~".$fid."~%' $searchadd and tid NOT IN $dellist and lastpost>=".min($stdt,$ltdt)." and lastpost<=".max($stdt,$ltdt));
        }
      }elseif($ltdt){
        if($dellist=="()"){
          $shadow=$db->query("SELECT tid,shadow FROM pw_threads WHERE shadow LIKE '%~".$fid."~%' $searchadd and lastpost>$ltdt");
        }else{
          $shadow=$db->query("SELECT tid,shadow FROM pw_threads WHERE shadow LIKE '%~".$fid."~%' $searchadd and tid NOT IN $dellist and lastpost>$ltdt");
        }
      }else{
        if($dellist=="()"){
          $shadow=$db->query("SELECT tid,shadow FROM pw_threads WHERE shadow LIKE '%~".$fid."~%' $searchadd ORDER BY $topadd $orderway $asc ".pwLimit($offset,$limit2));
        }else{
          $shadow=$db->query("SELECT tid,shadow FROM pw_threads WHERE shadow LIKE '%~".$fid."~%' $searchadd and tid NOT IN $dellist ORDER BY $topadd $orderway $asc ".pwLimit($offset,$limit2));
        }
      }
      $listofshadow='(';
      while($rt = $db->fetch_array($shadow)){
        if($listofshadow=="("){
          $listofshadow.=$rt['tid'];
        }else{
          $listofshadow.=",".$rt['tid'];
        }
        $limit2=$limit2+1;
      }
      $listofshadow.=')';
      $db->free_result($shadow);
      if($listofshadow=="()"){
        $query = $db->query("SELECT * FROM pw_threads WHERE $sql $searchadd ORDER BY $topadd $orderway $asc ".pwLimit($offset,$limit2));
      }else{
        $query = $db->query("SELECT * FROM pw_threads WHERE tid in ".$listofshadow." or $sql $searchadd ORDER BY $topadd $orderway $asc ".pwLimit($offset,$limit2));
      }
[/codes]
以上代码取代 
[codes=php]
$query = $db->query("SELECT * FROM pw_threads WHERE $sql $searchadd ORDER BY $topadd $orderway $asc ".pwLimit($offset,$limit2));
[/codes]
然后数据库里做相关配置就可以了~~ |
评分
-
查看全部评分
|