조건에 해당하는 게시물만 일괄삭제 가능한가요? > 그누4 질문답변

그누4 질문답변

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

조건에 해당하는 게시물만 일괄삭제 가능한가요? 정보

조건에 해당하는 게시물만 일괄삭제 가능한가요?

본문

wr_1 에 100 이란 숫자를 넣어놓으면

전체 게시물 중에 100에 일치하는 것들만 일괄삭제가 가능한가용?

도움좀 ~ㅜㅜ
  • 복사

댓글 전체

하나의 게시판에만 적용시키시는 것이 아니라 전체 게시판에 대해서 삭제를 원하신다면 그에 대해 코드가 작성된 PHP 페이지를 만드셔야 겠지요 :)

등록되어 있는 BOARD 게시판 정보를 우선 g4_board 테이블에서 검색해서 정보를 가져오고,
가져온 정보를 for 문을 돌려 각각의 table 명을 알아내서,
해당 테이블에서 wr_1 이 100 인 게시물들을 검색하신 다음에 ^^

게시판과 연동되어 있는 g4_board_file 이라거나 이런 쪽 DB 테이블에서 해당 게시물을 다시 한번 검색하여 연동되어 있는 데이터 까지 모두 삭제를 해 주시면 되겠죠 ~ :)



아래는 그누보드 게시물 delete 구문 입니다.
이 로직을 수행하기 전에 위에서 말씀 드렸듯이 게시판 정보 읽어 오고 -> 게시판 정보에서 table 정보 빼온 뒤 -> wr_1 의 값이 100인 게시글의 wr_id 정보 가져 오고 아래의 로직을 수행하면 됩니다.

$sql = " select wr_id, mb_id, wr_is_comment from $write_table where wr_parent = '$write[wr_id]' order by wr_id ";
$result = sql_query($sql);
while ($row = sql_fetch_array($result))
{
    // 원글이라면
    if (!$row[wr_is_comment])
    {
        // 원글 포인트 삭제
        if (!delete_point($row[mb_id], $bo_table, $row[wr_id], '쓰기'))
            insert_point($row[mb_id], $board[bo_write_point] * (-1), "$board[bo_subject] $row[wr_id] 글삭제");

        // 업로드된 파일이 있다면 파일삭제
        $sql2 = " select * from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$row[wr_id]' ";
        $result2 = sql_query($sql2);
        while ($row2 = sql_fetch_array($result2))
            @unlink("$g4[path]/data/file/$bo_table/$row2[bf_file]");
           
        // 파일테이블 행 삭제
        sql_query(" delete from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$row[wr_id]' ");

        $count_write++;
    }
    else
    {
        // 코멘트 포인트 삭제
        if (!delete_point($row[mb_id], $bo_table, $row[wr_id], '코멘트'))
            insert_point($row[mb_id], $board[bo_comment_point] * (-1), "$board[bo_subject] {$write[wr_id]}-{$row[wr_id]} 코멘트삭제");

        $count_comment++;
    }
}

// 게시글 삭제
sql_query(" delete from $write_table where wr_parent = '$write[wr_id]' ");

// 최근게시물 삭제
sql_query(" delete from $g4[board_new_table] where bo_table = '$bo_table' and wr_parent = '$write[wr_id]' ");

// 스크랩 삭제
sql_query(" delete from $g4[scrap_table] where bo_table = '$bo_table' and wr_id = '$write[wr_id]' ");

// 공지사항 삭제
$notice_array = explode("\n", trim($board[bo_notice]));
$bo_notice = "";
for ($k=0; $k<count($notice_array); $k++)
    if ((int)$write[wr_id] != (int)$notice_array[$k])
        $bo_notice .= $notice_array[$k] . "\n";
$bo_notice = trim($bo_notice);
sql_query(" update $g4[board_table] set bo_notice = '$bo_notice' where bo_table = '$bo_table' ");

// 글숫자 감소
if ($count_write > 0 || $count_comment > 0)
    sql_query(" update $g4[board_table] set bo_count_write = bo_count_write - '$count_write', bo_count_comment = bo_count_comment - '$count_comment' where bo_table = '$bo_table' ");
© SIRSOFT
현재 페이지 제일 처음으로