스티커 모듈 판매수 코드 문의 보고하비 2017.07.19 04:39 181 0 17 {$sticker->bought_count} 판매수 코드가 위와 같이 되어있는데 판매수가 전혀 올라가질 않고 있는데요 혹시 코드가 잘못된건가요?
관리자화면 "시스템 설정" 클릭시 오류 발생 후 해결. Attempt to assign property "site_srl" on array" in modules/module/module.model.php on line 157 hatali 25.12.26 0 0
댓글 17
$args = new stdClass();
$args->sticker_srl = $sticker_srl;
$output = executeQuery('sticker.updateBoughtCount', $args);
return !$output->toBool() ? FALSE : TRUE;
}
아래 쿼리가 문제인듯 한데요.. 저도 카운트가 안되서 제작자분께 문의 한 적이 있는데 특별한...
아마 서버환경에 따라 저게 안먹히는 거 같습니다.
저도 이것 좀 고칠 수 있으면 고쳐야 겠는데....
<query id="updateBoughtCount" action="update">
<tables>
<table name="sticker" />
</tables>
<columns>
<column name="bought_count" var="bought_count" default="plus(1)" />
</columns>
<conditions>
<condition operation="equal" column="sticker_srl" var="sticker_srl" filter="number" notnull="notnull" />
</conditions>
</query>
고수분께서 아마 답변을.....
$args = new stdClass();
$args->sticker_srl = $sticker_srl;
$bought_count = executeQuery('sticker.getBougthCount',$args)->data->bought_count;
$args->bought_count = $bought_count+1;
$output = executeQuery('sticker.updateBoughtCount', $args);
return !$output->toBool() ? FALSE : TRUE;
}
<query id="getBoughtCount" action="select">
<tables>
<table name="sticker" />
</tables>
<columns>
<column name="bought_count" var="bought_count" />
</columns>
<conditions>
<condition operation="equal" column="sticker_srl" var="sticker_srl" filter="number" notnull="notnull" />
</conditions>
</query>
<query id="updateBoughtCount" action="update">
<tables>
<table name="sticker" />
</tables>
<columns>
<column name="bought_count" var="bought_count" />
</columns>
<conditions>
<condition operation="equal" column="sticker_srl" var="sticker_srl" filter="number" notnull="notnull" />
</conditions>
</query>
이렇게 해 봤는데 잘 안되네요....
<columns>
<column name="bought_count" var="bought_count" />
</columns>
이부분을
<columns>
<column name="*" />
</columns>
이렇게 처리한다음 나머지는 그대로 유지하면 모든 데이터가 불러와져요.
그러면 executeQuery('sticker.getBougth',$args) 에서 가져온 값을 이용해서
$output->data->bought_count 를 가져올 수 있을꺼에요.
만약 data가 없는 경우 update가 안되니 insert으로 처리해야하고요.
function _increaseStickerBuyCount($sticker_srl){
$args = new stdClass();
$args->sticker_srl = $sticker_srl;
$output = executeQuery('sticker.getBougthCount',$args);
$bought_count = $output->data->bought_count;
$args = new stdClass();
$args->sticker_srl = $sticker_srl;
$args->bought_count = $bought_count+1;
$output = executeQuery('sticker.updateBoughtCount', $args);
return !$output->toBool() ? FALSE : TRUE;
}
<query id="getBoughtCount" action="select">
<tables>
<table name="sticker" />
</tables>
<columns>
<column name="*" />
</columns>
<conditions>
<condition operation="equal" column="sticker_srl" var="sticker_srl" filter="number" notnull="notnull" />
</conditions>
</query>
<query id="updateBoughtCount" action="update">
<tables>
<table name="sticker" />
</tables>
<columns>
<column name="bought_count" var="bought_count" />
</columns>
<conditions>
<condition operation="equal" column="sticker_srl" var="sticker_srl" filter="number" notnull="notnull" />
</conditions>
</query>
여기를 건드릴게 아닌거 같아요... ㅡㅡ;
$checkBuyHistoryToday = $this->_checkBuyStickerToday($member_srl, $sticker_srl);
if($sticker->member_srl != $member_srl && $checkBuyHistoryToday === 0){
$this->_increaseStickerBuyCount($sticker_srl);
}
이런 코드가 보이네요..
일단 원래대로 돌려 놓고 오늘은 포기하고 나중에 어디가 문제인지 다시 봐야 겠어요.
$this->_increaseStickerBuyCount($sticker_srl);
}
저기서 && $checkBuyHistoryToday === 0 이걸 빼버리니 증가하네요.
뭔지 모르지만 그냥 빼는거로 마무리요 ㅋ
controll.php 파일에
320번줄 밑으로 보시면
if($sticker->member_srl != $member_srl && $checkBuyHistoryToday === 0){
$this->_increaseStickerBuyCount($sticker_srl);
}
여기서 && $checkBuyHistoryToday === 0 제거해 보세요. 저는 그것 제거하고 구매 즉시 올라가네요.