불당님 튜닝 개선 - min_wr_num

· 16년 전 · 2949
원문 : http://www.sir.co.kr/bbs/board.php?bo_table=g4_tiptech&wr_id=15206

대상페이지 : /bbs/write_update.php

wr_num 는 답글 및 수정에는 변경되지 않습니다.
답글이 아닌 글 작성시에만 변경 되는데.

- 277 line
$wr_num = get_next_num($write_table);

이미 $wr_num 을 가져오는게 있습니다.

그렇다면 min_wr_num = '$wr_num' 하면 되겠지만
326 line 라인에서 '게시글 1증가' 할때 board_table을 update 합니다.

----
// 추가 코드
if ($w == '') $sql_wr_num = ', min_wr_num = '.$wr_num;

// 게시글 1 증가
sql_query("update $g4[board_table] set bo_count_write = bo_count_write + 1 ".$sql_wr_num." where bo_table = '$bo_table'");
----

이제 추가 쿼리 없이 min_wr_num 이 update 됩니다.

delete 시에는
$result = sql_fetch(" select MIN(wr_num) as min_wr_num from $write_table ");
// 추가 IF
if ($result[min_wr_num] != $board['min_wr_num']) {
  $sql = " update $g4[board_table] set min_wr_num = '$result[min_wr_num]' where bo_table = '$bo_table' ";
  sql_query($sql);
}
이런식으로 하시면 불필요한 쿼리가 줄어들기는 합니다.
|

댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기
🐛 버그신고