미채택 완료

특정 일이 지난 댓글을 삭제되게 했는데요

2020-12-19 (토) 05:15:47 2,598

안녕하세요.

해피정님 특정 기간 글 자동 삭제를 댓글만 삭제되게 해서 사용하려고 하는데요.

원하는 기능은 잘 실행이 되고 있는데 댓글 수 카운트가 업데이트가 안되고 있어요.

뭐가 잘못된걸까요?

Copy
<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가

// 특정게시판에 적용하고 싶을때  Start
$ttable = array('123', '456', '789');
foreach($ttable as $t) {
    $tbo_table = $t;
// 특정게시판에 적용하고 싶을때  End

/*
// 전체게시판에 적용하고 싶을때  Start
$sql = "select * from {$g5['board_table']} order by bo_table asc ";
$result = sql_query($sql);
while($data = sql_fetch_array($result)) {
    $tbo_table = $data["bo_table"];
// 전체게시판에 적용하고 싶을때  End
*/
    
sql_query(" delete from {$g5['write_prefix']}{$tbo_table} where wr_datetime < date_add(now(), interval -30 day) and wr_is_comment = 1");

 

    // 게시판의 코멘트 수
    $sql = " select count(*) as cnt from {$g5['write_prefix']}{$bo_table} where wr_is_comment = 1 ";
    $row = sql_fetch($sql);
    $bo_count_comment = $row['cnt'];    

    if (isset($_POST['proc_count'])) {
        // 원글을 얻습니다.
        //$sql = " select wr_id from {$g5['write_prefix']}{$bo_table} where wr_is_comment = 0 ";
        $sql = " select a.wr_id, (count(b.wr_parent) - 1) as cnt from {$g5['write_prefix']}{$bo_table} a, {$g5['write_prefix']}{$bo_table} b where a.wr_id=b.wr_parent and a.wr_is_comment=0 group by a.wr_id ";
        $result = sql_query($sql);
        for ($i=0; $row=sql_fetch_array($result); $i++) {
            /*
            // 코멘트수를 얻습니다.
            $sql2 = " select count(*) as cnt from {$g5['write_prefix']}$bo_table where wr_parent = '{$row['wr_id']}' and wr_is_comment = 1 ";
            $row2 = sql_fetch($sql2);
            */

            sql_query(" update {$g5['write_prefix']}{$bo_table} set wr_comment = '{$row['cnt']}' where wr_id = '{$row['wr_id']}' ");
        }
    }

}
?>
|

답변 1개 / 댓글 1개

2020-12-19 (토) 12:56:52
wr_comment = '{$row['cnt']}'

=> 이게 아래처럼 변경되야 겠네요

wr_comment = '{$bo_count_comment}'

답변에 대한 댓글 1개

$bo_count_comment = $row['cnt'];

이미 선언이 되어 잇는거 아닌가요?

일단 말씀하신 데로 변경해 봤는데 안되네요 ㅠㅠ

답변을 작성하려면 로그인이 필요합니다.