코멘트 작성시 시간에 따라 + 표시가 생기는 것을 적용했는데... > 그누4 질문답변

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기
기존 게시물은 열람만 가능합니다.

코멘트 작성시 시간에 따라 + 표시가 생기는 것을 적용했는데... 정보

코멘트 작성시 시간에 따라 + 표시가 생기는 것을 적용했는데...

본문

예전에 작성했었는데,
답변에 대해 별 성과가 없어서 다시 이렇게 올립니다.


 //코멘트 + 표시 타임
  $intime = date("Y-m-d H:i:s", time() - (int)(60 * 60 * 24));  //하루
  $intime2 = date("Y-m-d H:i:s", time() - (int)(60 * 60 * 24 *2));  //이틀
 
  $co_wr_parent = $list[$i][wr_id];
  $co_wr_comment =substr($list[$i][comment_cnt],1,1);
 
  $sqlcomm = "SELECT count(*) AS cnt FROM $write_table WHERE wr_is_comment = '1' and wr_parent = '$co_wr_parent' and wr_datetime >='$intime'";
  $row = sql_fetch($sqlcomm);
 
  $sqlcomm2 = "SELECT count(*) AS cnt FROM $write_table WHERE wr_is_comment = '1' and wr_parent = '$co_wr_parent' and wr_datetime >='$intime2'";
  $row2 = sql_fetch($sqlcomm2);
 
    if ($row[cnt])
        echo " <a href=\"{$list[$i][comment_href]}\"><span style='font-family:Tahoma;font-size:10px;color:#747474;'>{$list[$i][comment_cnt]}</span></a> <span style='font-family:Tahoma;font-size:9px;color:#FF0000;'>+</span>";
  else if ($row2[cnt])
        echo " <a href=\"{$list[$i][comment_href]}\"><span style='font-family:Tahoma;font-size:10px;color:#747474;'>{$list[$i][comment_cnt]}</span></a> <span style='font-family:Tahoma;font-size:9px;color:#2080D0;'>+</span>";
  else
        echo " <a href=\"{$list[$i][comment_href]}\"><span style='font-family:Tahoma;font-size:10px;color:#747474;'>{$list[$i][comment_cnt]}</span></a>";
 
 
...
 
 
코멘트를 작성하면,
List에 + 표시가 생기는데..
하루동안은 빨간색, 이틀까지는 파란색.. 그 이후로는 없어지는 소스입니다.
 
잘 됩니다. ^^
 
 
그런데 ... !!
DB부하가 엄청 일어나서, 서버측의 권고로 차단했는데..
이 기능을 꼭 사용해야 하는터라..
 
소스를 간략하게 줄이거나 부하를 해결할 수 있는 방법이 없을까요?
아니면 아예 새로이 바꿔주셔도 감사합니다.
 
 
도움 부탁드립니다~!!

댓글 전체

$sqlcomm = "SELECT count(*) AS cnt FROM $write_table WHERE wr_is_comment = '1' and wr_parent = '$co_wr_parent' and wr_datetime >='$intime'";

위의 쿼리쪽부분에 index를 타게 하세요. 음..일단 그부보드의 게시판쪽 인덱스필드는 wr_id이고 그이외의 보조키가 wr_num,wr_reply,wr_parent,wr_is_comment 등이 있습니다.

시간은 키값에 해당하지 않는다는거죠..음..그렇다면
어차피 시간에 맞춰서 뽑아오는거니까..

$sqlcomm = "SELECT count(*) AS cnt FROM $write_table WHERE wr_is_comment = '1' and wr_parent = '$co_wr_parent' and wr_datetime >='$intime' order by wr_num desc";

이렇게 한번 해보시죠..그나마 빨라질듯

추신: 테이블내에 선언되 키필드를 통해 검색해는게 대용량의 경우 속도면에서 우월하답니다.
전체 66,554 |RSS
그누4 질문답변 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1402호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT