나리야 경험치 내역 압축하는 방법 문의드립니다. 채택완료
포인트 내역 압축은 자료실에 있는
자료로 DB용량을 획기적으로 줄일수 있어서,
나리야 경험치 내역도 같은 원리로 압축할수 있지 않을까 해서
수정해보아도 잘 적용이 되지않아
고수님들께 문의 드려 봅니다.
</p>
<p><?php
$sub_menu = "200201";
include_once('./_common.php');</p>
<p>auth_check($auth[$sub_menu], 'w');</p>
<p>check_token();</p>
<p>// 변수 설정입니다. 필요에 맞게 설정하세요.
$year = $_POST['year'];
$cut = $_POST['number'];
$min = 0; // 그 해에 포인트가 10건 이하이면 압축하지 않습니다.</p>
<p>// 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%'";</p>
<p> // 복사했으니 삭제해버리기
$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(''));</p>
<p> // 압축한 건수를 더함
$total_cnt += $row['cnt'];
}</p>
<p>echo '<meta http-equiv="content-type" content="text/html; charset=utf-8" />';
echo $i . '명의 ' . $year . '년도 경험치 ' . $total_cnt . '건을 정리하였습니다.
';
if($i == $cut) echo 'F5를 누르면 추가로 적용됩니다. <a href="./point_list.php?'.$qstr.'">[여기]</a> 를 누르시면 포인트관리 페이지로 이동됩니다.';
?></p>
<p>
답변 1개
php 7.4 에서 에러 안나도록 수정한 코드입니다
실제 테스트트 안해봤습니다
'{$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 ''; echo $i . '명의 ' . $year . '년도 경험치 ' . $total_cnt . '건을 정리하였습니다. '; if($i == $cut) echo 'F5를 누르면 추가로 적용됩니다. [여기] 를 누르시면 포인트관리 페이지로 이동됩니다.'; ?>
답변에 대한 댓글 1개
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
근데 어디가 문제인지 작동은 하지 않네요
참고로 말씀드리면 해당 코드를 xp_zip.php 로 저장하여
root/nariya/extend/membership 에 넣었습니다.
그 후 같은 폴더에 있는 admin_xp.php 에서 아래 코드를 알맞은곳에 추가했습니다.
[code]
<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>
[/code]