업대이트 문 효율성 좀 질문좀 드릴께요 ? ^^ > 그누4 질문답변

그누4 질문답변

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

업대이트 문 효율성 좀 질문좀 드릴께요 ? ^^ 정보

업대이트 문 효율성 좀 질문좀 드릴께요 ? ^^

본문

아래와 같이 똑같은 조건으로 .


if ($member[mb_id]) {
    $rate = 15; //★평가포인트 = 평가점수 * $rate

    //원글 정보
    $arr = sql_fetch("select mb_id from $write_table where wr_id='$wr_id'");
    $source_mb_id = $arr[mb_id]; //원글 작성자의 id
   
    //평가점수를 준 자신의 코멘트 정보들
    $arr2 = mysql_fetch_array(mysql_query("select count(*) from $write_table where wr_parent = '$wr_id' and wr_is_comment ='1' and wr_11 > 0 and mb_id = '$member[mb_id]'"));
    $already = $arr2[0] - 1; //원글에 평가점수를 준 자신의 코멘트 갯수 (현재꺼 제외)

    //코멘트 수정시 조건을 위해 정보필요
    if ($w == "cu") {
        $arr3 = mysql_fetch_array(mysql_query("select wr_11 from $write_table where where wr_id='$comment_id'"));
        $old_score = $arr3[0] * $rate; //수정하려는 코멘트의 평가점수
    }

    //동일인(원글=코멘트작성인) 또는 이미 1개이상 평가점수 준 회원인가? 또는 원글작성자가 비회원인가..
    $limit = 1; //한 사람당 평가점수 줄 수 있는 갯수
    if (($w == "c" && $member[mb_id] == $source_mb_id) || ($w == "c" && $already >= $limit) || !$source_mb_id) {

        @mysql_query("update $write_table set wr_11='' where wr_id='$comment_id'"); //평가점수 취소


    } else {
   
        //원글에 결과 기록작업
        //평가점수가 있는 코멘트 정보만 가져온다.
        $result = sql_query("select wr_11 from $write_table where wr_parent = '$wr_id' and wr_is_comment ='1' and mb_id != '$source_mb_id' and wr_11 > 0 ");
        $total_count = mysql_num_rows($result); //참여인원
        if ($total_count) {
            for ($i=0; $row=sql_fetch_array($result); $i++) {
                $sum_score += $row[wr_11]; //평가점수합계
                $sum_point += $row[wr_11] * $rate; //평가포인트합계
            }
            $average_score = $sum_score / $total_count; //평균점수
            //원글의 wr_11필드에 "평균점수|참여인원|평가포인트합계|점수합계"를 구분자(|)와 함께 기록
            @mysql_query("update $write_table set wr_11='$average_score|$total_count|$sum_point|$sum_score' where wr_id='$wr_id'");
        }
       
    }
}



지금아래는 wr_11만 업대이트 시키는걸 예로 되어 있는데 ..
만약 위와 같이 똑같이 내용을 wr_11 wr_12 wr_13 wr_14 wr_15  wr_16  wr_17  wr_18 wr_19

전부 업대이트 시켜 줘야 한다면 .. 어떻게 짜는게 가장 효율적인가요 ?

위와 같은 내용을 그냥 복사 해서 아래로 계속 붙여 넣기 해서 숫자만 바꾸워 줘도
업대이트가 되긴 하는데 ..
상당히 비효율적일거 같고 .. 그렇게 해도 아무 상관 없나요 ??

댓글 전체

MSTUDIO님처럼  한게시물에 여러개 평가달기위해서 나름 고민했는데 복사해서 찾기 바꾸기로 했다눈...

평가가 늘 발생하지 않으니 처리하는데 채감속도는 거의 없습니다.
깔끔하지 않고 소스라인이 길어진다는 압박만....

전체만족도 ★★★★☆  시설 ★★★★★  친절 ★★★☆☆  청결 ★★★★☆ 

좋은 방법 있으면 알려주세요. 저도 이 질문에 답을 기다립니다.
@mysql_query("update $write_table set wr_11='$average_score', wr_12='$total_count', wr_13='$sum_point', wr_14='$sum_score' where wr_id='$wr_id'");

이렇게 하는 건가요? 이렇게 하면 explode 를 한번 않 쓴다는 효율성? 음...
별 차이 없는듯...
select count(*) from $write_table where wr_parent = '$wr_id' and wr_is_comment ='1'
and wr_11 > 0 and mb_id = '$member[mb_id]'

=>

select sum( if( wr_11>0, 1, 0) wr_11_sum,
sum( if( wr_12>0, 1, 0) wr_12_sum,
sum( if( wr_13>0, 1, 0) wr_13_sum,
...
  from $write_table where wr_parent = '$wr_id' and wr_is_comment ='1'
 and mb_id = '$member[mb_id]'
전체 66,554 |RSS
그누4 질문답변 내용 검색

회원로그인

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