전체선택 선택삭제하면 전체 게시물 수가 마이너스(-)로 내려갈때

그냥 삭제하면 괜찮은데, 게시물 목록 보기에서 전체 선택 삭제를 하면 전체 게시물 수가 마이너스(-) 이하로 내려가 버리는 문제가 생겨서 gbdeleteall.php에서 마지막쯤의 header(...) 함수 윗 부분을 고쳐서 해결 했습니다.

---------------------------------고치기 전----------------------------------------
// 파일삭제
@unlink($gnu_path . "data/file/$bo_table/write[wr_file1]");
@unlink($gnu_path . "data/file/$bo_table/write[wr_file2]");

// 게시글 1 감소
sql_query_error("update $cfg[table_board] set bo_total_count = bo_total_count - 1 where bo_table = '$bo_table'");
}

header("location:gnuboard.php?$qstr&page=$page");

---------------------------------고친 후----------------------------------------
// 파일삭제
@unlink($gnu_path . "data/file/$bo_table/write[wr_file1]");
@unlink($gnu_path . "data/file/$bo_table/write[wr_file2]");

// 게시글 1 감소
if(mysql_affected_rows($connect) > 0) {
sql_query_error("update $cfg[table_board] set bo_total_count = bo_total_count - 1 where bo_table = '$bo_table'");
}
}

header("location:gnuboard.php?$qstr&page=$page");

----------------------------- 해설 ---------------------------------
'mysql 연결에서 delete 쿼리로 인해 영향을 받았을 때만 총 게시물 수를 조정하여라~' 입니다.
|

댓글 1개

전 이렇게 했죠...
update $cfg[table_board] set bo_total_count = bo_total_count - 1 where bo_table = '$bo_table' and bo_total_count >0

댓글 작성

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

로그인하기
🐛 버그신고