채택완료

포인트 소멸? 초기화 ?

2021-11-09 (화) 00:51:00 1,801

아래 는 전체회원 포인트 초기화 php 실행문 입니다.
혹시 여기서
전체회원 이 아닌. 특정 DB테이블. 시작 과 마지막 날짜 (EX: 2021-11월1일부터 ~ 2021-11월30) 까지 지급받은 포인트 초기화. 또는 소멸 가능할까요 ?

이벤트 포인트 지급테이블이 @event 로 되어있다는 가정입니다.
아니면

UPDATE {$g5['member_table']} SET']}

으로

해당 event테이블 설정기간 안에 지급된 포인트 들만 포인트 만료일 실행시키고싶습니다

Copy
<?php
include_once('./_common.php');

if ($is_admin != 'super') {
  alert('최고관리자만 가능합니다.', G5_URL);
}

// 포인트 전체 초기화
sql_query(" delete from {$g5['point_table']} ");
sql_query(" alter table {$g5['point_table']} auto_increment=1 ");
sql_query(" update {$g5['member_table']} set mb_point=0 ");
alert('초기화되었습니다.', G5_URL);
?>
|

답변 1개 / 댓글 20개

채택된 답변
+20 포인트
2021-11-09 (화) 08:04:23

update {$g5['member_table']} A inner join event B 

on A.멤버아이디 = B.멤버아이디

set mb_point = 0 

where B.완료날짜 between '2021-11-01 00:00:00' and '2021-11-31 23:59:59'

답변에 대한 댓글 20개

감사합니다.
그렇다면.
아이디 지정안하면.

event
테이블 에 있는.
between (해당기간) 날짜 값들 모두 변경될까요 ?
[code]
<?php
include_once('./_common.php');
if ($is_admin != 'super') {
alert('최고관리자만 가능합니다.', G5_URL);
}
update {$g5['member_table']} A inner join event B

set mb_point = 0

where B.완료날짜 between '2021-11-01 00:00:00' and '2021-11-31 23:59:59'
alert('초기화되었습니다.', G5_URL);
?>
[/code]
이렇게요
멤버 아이디가 특정 아이디가 아니에요
event 테이블이랑 member_table 의 join key 이기 때문에 있어야 됩니다.

A.member_id = B.member_id 이런식으로요

만약 특정 아이디를 지정하고 싶으면 where 조건뒤에 and A.member_id = 'aaaa' 이런식으로 쓰겠죠
친절하게 말씀해주셔서 감사합니다.
특정아이디를 사용할게 아니면.
아래처럼 구현해보도록 하겠습니다. 공부하는데.. 많은 도움이됩니다.. 혹시라도 틀린점있다면 잡아주시면 감사하겠습니다..

[code]
<?php
include_once('./_common.php');
if ($is_admin != 'super') {
alert('최고관리자만 가능합니다.', G5_URL);
}
$sql = "update {$g5['member_table']} A inner join event B

on A.member_id = B.member_id

set mb_point = 0

where B.완료날짜 between '2021-11-01 00:00:00' and '2021-11-31 23:59:59'";
alert('초기화되었습니다.', G5_URL);
?>
[/code]
네 컬럼 이름이랑 날짜만 정확하게 확인하시면 될겁니다. ㅎㅎ
말씀해주신대로.. 처리했는데..ㅠㅠ
관리자 들어가서보거나.
DB 들어가보면 초기화 안되어 있습니다..ㅠㅠ
테이블을 포인트 테이블로 변경해줘야할까요 ?
db 에서는 일단 포인트 테이블 은 아래처럼 기제되어있습니다. 칼럼이 맞는지..ㅠㅠㅠㅠㅠ




po_id = 532
mb_id = admin
po_datetime = 2021-11-09 09:39:04
po_content = 2021-11-09 09:39:03에 이벤트 지급
po_point = 500
po_use_point = 0
po_expired = 0
po_expire_date = 9999-12-31
po_mb_point = 2502
po_rel_table = @event
po_rel_id = admin
po_rel_action = 2021-11-09 09:39:04
member table 도 보여주세요
mb_id
mb_password
mb_name
mb_nick
mb_nick_date
mb_email
mb_homepage
mb_level
mb_sex
mb_birth
mb_tel
mb_hp
mb_certify
mb_adult
mb_dupinfo
mb_zip1
mb_zip2
mb_addr1
mb_addr2
mb_addr3
mb_addr_jibeon
mb_signature
mb_recommend
mb_point
mb_today_login
mb_login_ip
mb_datetime
mb_ip
mb_leave_date
mb_intercept_date
mb_email_certify
mb_email_certify2
mb_memo
mb_lost_certify
mb_mailling
mb_sms
mb_open
mb_open_date
mb_profile
mb_memo_call
mb_memo_cnt
mb_scrap_cnt
mb_1
mb_2
mb_3
mb_4
mb_5
mb_6
mb_7
mb_8
mb_9
mb_10
mb_is_noti
mb_noti_cnt


이렇게 있습니다!
member_id => mb_id
완료날짜 => po_expire_date
아래처럼 하는게맞는지요^^?
친절하게 알려주셔서 너무너무 감사합니다.

[code]

<?php
include_once('./_common.php');
if ($is_admin != 'super') {
alert('최고관리자만 가능합니다.', G5_URL);
}
$sql = "update {$g5['member_table']} A inner join event B

on A.mb_id = B.mb_id

set mb_point = 0

where B.완료날짜 po_expire_date '2021-11-01 00:00:00' and '2021-11-31 23:59:59'";
alert('초기화되었습니다.', G5_URL);
?>

[/code]
B.완료날짜 po_expire_date 가 아니라
B.po_expire_date between 으로 하셔야죠 ㅎㅎ

근데 sql 실행하는 부분이 없네요?

sql_query($sql);
앗 그럼 이렇게 하고.
sql 실행부분 어느부분에 넣어야할까용?ㅠㅠ
저는 이렇게하면 다되는줄..ㅠㅠ


[code]

<?php
include_once('./_common.php');
if ($is_admin != 'super') {
alert('최고관리자만 가능합니다.', G5_URL);
}
$sql = "update {$g5['member_table']} A inner join event B

on A.mb_id = B.mb_id

set mb_point = 0

where B.po_expire_date between '2021-11-01 00:00:00' and '2021-11-31 23:59:59'";
alert('초기화되었습니다.', G5_URL);
?>

[/code]
alert 문장 위에다가 쓰셔야죠

sql_query($sql);
alert ~~

스무 고갠줄 ㅎㅎ
죄송합니당.
혼자.. 구글링. 책으로만 공부하다보니.. 완전 초보입니다..ㅠㅠ
문법 쿼리공부좀 더해야겠네용 ㅠㅠ

아래처럼 하고 실행 해봤으나. 포인트 변동이없습니당 엉엉엉 ㅠㅠㅠㅠㅠㅠ
무엇이 문제일까용..ㅠㅠㅠㅠㅠ

[code]

<?php
include_once('./_common.php');
if ($is_admin != 'super') {
alert('최고관리자만 가능합니다.', G5_URL);
}
$sql = "update {$g5['member_table']} A inner join @event B

on A.mb_id = B.mb_id

set mb_point = '0'

where B.po_expire_date between '2021-11-01 00:00:00' and '2021-11-31 23:59:59'";

sql_query($sql);

alert('초기화되었습니다.', G5_URL);
?>

[/code]
포인트 테이블이 이름이 event 라고 가정한다고 해서 그렇게 적었더니 그대로 적으셨네요

포인트 테이블이 이름이 @event 인가요 ㅋㅋ
g5_point 에서 / po_rel_table 부분에 .

@event
이렇게 표기되고있습니다!

포인트 지급시. g5_point
"po_rel_table 에 @event 로 포인트 지급됩니다.
그냥 event 대신에 g5_point 이라고 적으세요
말씀해주신대로..

$sql = "update {$g5['member_table']} A inner join g5_point B

on A.mb_id = B.mb_id

set mb_point = '0'

where B.po_expire_date between '2021-11-01 00:00:00' and '2021-11-31 23:59:59'";

sql_query($sql);


처리를 하여도 .. 변동이없네용..ㅠㅠ;;

아니면 저의 생각으로 한번만들어봤는데..
이렇게도 될까요 ?
[code]

$sql = "UPDATE {$g5['g5_point']} SET po_expire_date='2021-11-31' WHERE po_rel_table='event'";

[/code]
제가 구조를 완벽히 알지 못하니 추가 답변은 힘들겟네요
감사합니다

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