천

포인트와 같은방식으로 경험치를 추가해봤는대요..

· 2010-11-21 (일) 23:58:53 · 1260 · 2
포인트와 같은방식으로 경험치를 추가해봤는대요

뭔가빼먹었는지 몇군데에서 차이가 나는군요;;

게시물을 삭제하면 포인트의 경우에는 포인트내역에서 삭제됩니다.

하지만 경험치의 경우에는 경험치내역에서 삭제되지 않고 추가로 "어떤글삭제" 라고 나옵니다.

많은 문제는 되지 않는대 데이터양이 많아지면 불편할것 같아서요

포인트기능중에 "어떤글삭제" 를 추가하지 않고 데이터를 삭제하는부분을
찾아주시면 감사하겠습니다.

ps. common.lip.php 의 해당부분 입니다.
딱히 활동량 삭제 부분에서 db 에 insert 하는 부분은 안보이는대 말이죠 ;;
삭제하는 부분은 보이는대 ㅠㅠ

// 포인트 부여
function insert_point($mb_id, $point, $content='', $rel_table='', $rel_id='', $rel_action='')
{
global $config;
global $g4;
global $is_admin;

// 포인트 사용을 하지 않는다면 return
if (!$config[cf_use_point]) { return 0; }

// 포인트가 없다면 업데이트 할 필요 없음
if ($point == 0) { return 0; }

// 회원아이디가 없다면 업데이트 할 필요 없음
if ($mb_id == "") { return 0; }
$mb = sql_fetch(" select mb_id from $g4[member_table] where mb_id = '$mb_id' ");
if (!$mb[mb_id]) { return 0; }

// 이미 등록된 내역이라면 건너뜀
if ($rel_table || $rel_id || $rel_action)
{
$sql = " select count(*) as cnt from $g4[point_table]
where mb_id = '$mb_id'
and po_rel_table = '$rel_table'
and po_rel_id = '$rel_id'
and po_rel_action = '$rel_action' ";
$row = sql_fetch($sql);
if ($row[cnt])
return -1;
}

// 포인트 건별 생성
$sql = " insert into $g4[point_table]
set mb_id = '$mb_id',
po_datetime = '$g4[time_ymdhis]',
po_content = '".addslashes($content)."',
po_point = '$point',
po_rel_table = '$rel_table',
po_rel_id = '$rel_id',
po_rel_action = '$rel_action' ";
sql_query($sql);

// 포인트 내역의 합을 구하고
$sql = " select sum(po_point) as sum_po_point from $g4[point_table] where mb_id = '$mb_id' ";
$row = sql_fetch($sql);
$sum_point = $row[sum_po_point];

// 포인트 UPDATE
$sql = " update $g4[member_table] set mb_point = '$sum_point' where mb_id = '$mb_id' ";
sql_query($sql);

return 1;
}

// 포인트 삭제
function delete_point($mb_id, $rel_table, $rel_id, $rel_action)
{
global $g4;

$result = false;
if ($rel_table || $rel_id || $rel_action)
{
$result = sql_query(" delete from $g4[point_table]
where mb_id = '$mb_id'
and po_rel_table = '$rel_table'
and po_rel_id = '$rel_id'
and po_rel_action = '$rel_action' ", false);

// 포인트 내역의 합을 구하고
$sql = " select sum(po_point) as sum_po_point from $g4[point_table] where mb_id = '$mb_id' ";
$row = sql_fetch($sql);
$sum_point = $row[sum_po_point];

// 포인트 UPDATE
$sql = " update $g4[member_table] set mb_point = '$sum_point' where mb_id = '$mb_id' ";
$result = sql_query($sql);
}

return $result;
}

// 활동량 부여
function insert_active($mb_id, $active, $content='', $rel_table='', $rel_id='', $rel_action='')
{
global $config;
global $g4;
global $is_admin;

// 포인트 사용을 하지 않는다면 return
if (!$config[cf_use_point]) { return 0; }

// 포인트가 없다면 업데이트 할 필요 없음
if ($active == 0) { return 0; }

// 회원아이디가 없다면 업데이트 할 필요 없음
if ($mb_id == "") { return 0; }
$mb = sql_fetch(" select mb_id from $g4[member_table] where mb_id = '$mb_id' ");
if (!$mb[mb_id]) { return 0; }

// 이미 등록된 내역이라면 건너뜀
if ($rel_table || $rel_id || $rel_action)
{
$sql = " select count(*) as cnt from g4_active
where mb_id = '$mb_id'
and po_rel_table = '$rel_table'
and po_rel_id = '$rel_id'
and po_rel_action = '$rel_action' ";
$row = sql_fetch($sql);
if ($row[cnt])
return -1;
}

// 활동량 건별 생성
$sql = " insert into g4_active
set mb_id = '$mb_id',
po_datetime = '$g4[time_ymdhis]',
po_content = '".addslashes($content)."',
po_point = '$active',
po_rel_table = '$rel_table',
po_rel_id = '$rel_id',
po_rel_action = '$rel_action' ";
sql_query($sql);

// 활동량 내역의 합을 구하고
$sql = " select sum(po_point) as sum_po_point from g4_active where mb_id = '$mb_id' ";
$row = sql_fetch($sql);
$sum_active = $row[sum_po_point];

// 활동량 UPDATE
$sql = " update $g4[member_table] set mb_2 = '$sum_active' where mb_id = '$mb_id' ";
sql_query($sql);

return 1;
}

// 활동량 삭제
function delete_active($mb_id, $rel_table, $rel_id, $rel_action)
{
global $g4;

$result = false;
if ($rel_table || $rel_id || $rel_action)
{
$result = sql_query(" delete from g4_active
where mb_id = '$mb_id'
and po_rel_table = '$rel_table'
and po_rel_id = '$rel_id'
and po_rel_action = '$rel_action' ", false);

// 활동량 내역의 합을 구하고
$sql = " select sum(po_point) as sum_po_point from g4_active where mb_id = '$mb_id' ";
$row = sql_fetch($sql);
$sum_active = $row[sum_po_point];

// 활동량 UPDATE
$sql = " update $g4[member_table] set mb_2 = '$sum_active' where mb_id = '$mb_id' ";
$result = sql_query($sql);
}

return $result;
}
|

댓글 2개

2010-11-22 (월) 00:53:06
해결했내요 -ㅅ- ;; 이런실수 ㅠㅠ
해결하셨으면 저한테 베스트답변을...
댓글을 작성하시려면 로그인이 필요합니다.

그누4 질문답변

66,531건

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

+
제목 글쓴이 날짜 조회
10-11-22 조회 1,557
10-11-22 조회 1,169
10-11-21 조회 1,261
10-11-21 조회 1,899
10-11-21 조회 964
10-11-21 조회 1,713
10-11-21 조회 1,125
10-11-21 조회 1,697
10-11-21 조회 904
10-11-21 조회 1,766
10-11-21 조회 927
10-11-21 조회 905
10-11-21 조회 1,659
10-11-21 조회 914
10-11-21 조회 1,637
10-11-21 조회 967
10-11-21 조회 1,076
10-11-21 조회 2,510
10-11-20 조회 928
10-11-20 조회 1,796