특정 칼럼이 있다면 변경하고, 없으면 만들기.. SELECT COUNT(*)안쓰고..
point테이블에 특정 칼럼이 있으면 포인트 필드의 포인트만 증기시키고, 칼럼이 없으면 칼럼을 만들어야 되는데요,
SELECT COUNT(*)를 하고 fatch로 돌려서 할 수도 있지만..
$result = sql_query("update from $g4[point_table] set point=point+'$point'
where mb_id = '$mb_id'
and po_rel_table = '$rel_table'
and po_rel_id = '$rel_id'
and po_rel_action = '$rel_action' ", false);
if(!$result) sql_query("insert to $g4[point_table]~~~
이런식으로도 소스를 사용 할 수 있을까요? fatch를 쓰면 너무 지저분하고, 이게 하루에 수백번씩 접근되는 파일이라 최대한 깔끔하게 해야 되거든요. 오류 안생기게 한방에 해야되서.. 질문해 봅니다. 저런식의 소스도 가능한건가요??
SELECT COUNT(*)를 하고 fatch로 돌려서 할 수도 있지만..
$result = sql_query("update from $g4[point_table] set point=point+'$point'
where mb_id = '$mb_id'
and po_rel_table = '$rel_table'
and po_rel_id = '$rel_id'
and po_rel_action = '$rel_action' ", false);
if(!$result) sql_query("insert to $g4[point_table]~~~
이런식으로도 소스를 사용 할 수 있을까요? fatch를 쓰면 너무 지저분하고, 이게 하루에 수백번씩 접근되는 파일이라 최대한 깔끔하게 해야 되거든요. 오류 안생기게 한방에 해야되서.. 질문해 봅니다. 저런식의 소스도 가능한건가요??
|
댓글을 작성하시려면 로그인이 필요합니다.
댓글 3개
포인트 테이블에만 기록 되는 것이 아니라 회원 테이블에 포인트 총합을 기록하기 때문 입니다
저렇게 안된다면
$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]) {
update_point(231);
} else {
insert_point(231);
}
이런식으로 해야되구요.. 전 count방식을 사용하기 싫어서 그 부분만 해결 하려는 거거든요..
if(mysql_affected_rows() <1) insert문
그리고 update 쿼리문이 틀렸습니다
sql_query("update $g4[point_table] set po_point=po_point+'$point' ...............