나리야 경험치 내역 압축하는 방법 문의드립니다.

나리야 경험치 내역 압축하는 방법 문의드립니다.

QA

나리야 경험치 내역 압축하는 방법 문의드립니다.

본문

포인트 내역 압축은 자료실에 있는

https://sir.kr/g5_plugin/663

 

자료로 DB용량을 획기적으로 줄일수 있어서,

나리야 경험치 내역도 같은 원리로 압축할수 있지 않을까 해서

수정해보아도 잘 적용이 되지않아

고수님들께 문의 드려 봅니다.

 


<?php
$sub_menu = "200201";
include_once('./_common.php');
auth_check($auth[$sub_menu], 'w');
check_token();
// 변수 설정입니다. 필요에 맞게 설정하세요.
$year = $_POST['year'];
$cut = $_POST['number'];
$min = 0; // 그 해에 포인트가 10건 이하이면 압축하지 않습니다.
// po_datetime을 기준으로 해당 연도의 포인트 개수와 포인트 총합을 가져옴. (항목 많은 순서로 정렬)
$sql = "select `mb_id`, count(`xp_point`) as `cnt`, sum(`xp_point`) as `sum`
    from `$g5[na_xp]` where `xp_datetime` like '$year%'
    group by `mb_id` having cnt > '$min' order by `cnt` desc limit $cut";
$query = sql_query($sql);
$total_cnt = 0;
for($i=0; $row = sql_fetch_array($query); $i++) {
    $whereclause = "`mb_id` = '$row[mb_id]' and `xp_datetime` like '$year%'";
    // 복사했으니 삭제해버리기
    $sql = "delete from `$g5[na_xp]` where $whereclause";
    sql_query($sql);
    
    // 옮겼으니 압축된 항목 삽입하기
        na_insert_xp($row[mb_id], $row[sum], $year.'년 경험치 내역 - 압축', '@exp_zip', $row[mb_id], $member['mb_id'].'-'.uniqid(''));
    // 압축한 건수를 더함
    $total_cnt += $row['cnt'];
}
echo '<meta http-equiv="content-type" content="text/html; charset=utf-8" />';
echo $i . '명의 ' . $year . '년도 경험치 ' . $total_cnt . '건을 정리하였습니다.<br />';
if($i == $cut) echo 'F5를 누르면 추가로 적용됩니다. <a href="./point_list.php?'.$qstr.'">[여기]</a> 를 누르시면 포인트관리 페이지로 이동됩니다.';
?>

이 질문에 댓글 쓰기 :

답변 1

php 7.4 에서 에러 안나도록 수정한 코드입니다

실제 테스트트 안해봤습니다

 

<?php
$sub_menu = "200201";
include_once('./_common.php');
auth_check($auth[$sub_menu], 'w');
check_token();
// 변수 설정입니다. 필요에 맞게 설정하세요.
$year = $_POST['year'];
$cut = $_POST['number'];
$min = 0; // 그 해에 포인트가 10건 이하이면 압축하지 않습니다.
// po_datetime을 기준으로 해당 연도의 포인트 개수와 포인트 총합을 가져옴. (항목 많은 순서로 정렬)
$sql = "select `mb_id`, count(`xp_point`) as `cnt`, sum(`xp_point`) as `sum`
    from `{$g5['na_xp']}` where `xp_datetime` like '{$year}%'
    group by `mb_id` having cnt > '{$min}' order by `cnt` desc limit {$cut}";
$query = sql_query($sql);
$total_cnt = 0;
for($i=0; $row = sql_fetch_array($query); $i++) {
    $whereclause = "`mb_id` = '{$row['mb_id']}' and `xp_datetime` like '{$year}%'";
    // 복사했으니 삭제해버리기
    $sql = "delete from `{$g5['na_xp']}` where {$whereclause}";
    sql_query($sql);
    
    // 옮겼으니 압축된 항목 삽입하기
        na_insert_xp($row['mb_id'], $row['sum'], $year.'년 경험치 내역 - 압축', '@exp_zip', $row['mb_id'], $member['mb_id'].'-'.uniqid(''));
    // 압축한 건수를 더함
    $total_cnt += $row['cnt'];
}
echo '<meta http-equiv="content-type" content="text/html; charset=utf-8" />';
echo $i . '명의 ' . $year . '년도 경험치 ' . $total_cnt . '건을 정리하였습니다.<br />';
if($i == $cut) echo 'F5를 누르면 추가로 적용됩니다. <a href="./point_list.php?'.$qstr.'">[여기]</a> 를 누르시면 포인트관리 페이지로 이동됩니다.';
?>

답변 정말정말 감사합니다.
근데 어디가 문제인지 작동은 하지 않네요

참고로 말씀드리면 해당 코드를 xp_zip.php 로 저장하여
root/nariya/extend/membership 에 넣었습니다.

그 후 같은 폴더에 있는 admin_xp.php 에서 아래 코드를 알맞은곳에 추가했습니다.


    <h2 class="h2_frm">경험치 내역 압축 플러그인</h2>
    <form name="fpointlist1" method="post" id="fpointlist1" action="./xp_zip.php" autocomplete="off">
    <div class="tbl_frm01 tbl_wrap">
        <table>
        <colgroup>
            <col class="grid_4">
            <col>
        </colgroup>
        <tbody>
        <tr>
            <th scope="row"><label for="year">압축년도<strong class="sound_only">필수</strong></label></th>
            <td><input type="text" name="year" value="<?php echo $year ?>" id="year" class="required frm_input" required></td>
        </tr>
        <tr>
            <th scope="row"><label for="number">압축회원수<strong class="sound_only">필수</strong></label></th>
            <td><input type="text" name="number" value="<?php echo $number ?>" id="number" class="required frm_input" required></td>
        </tr>
        </tbody>
        </table>
    </div>
 
    <div class="btn_confirm01 btn_confirm">
        <input type="submit" value="확인" class="btn_submit">
    </div>
 
    </form>

답변을 작성하시기 전에 로그인 해주세요.
전체 16
QA 내용 검색

회원로그인

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