shop/orderform.php 코드문의드립니다.

shop/orderform.php 코드문의드립니다.

QA

shop/orderform.php 코드문의드립니다.

본문

shop/orderform.sub.php 중 일부입니다.

 

            // 합계금액 계산
            $sql = " select SUM(IF(io_type = 1, (io_price * ct_qty), ((ct_price + io_price) * ct_qty))) as price,
                            SUM(ct_point * ct_qty) as point,
                            SUM(ct_qty) as qty
                        from {$g5['g5_shop_cart_table']}
                        where it_id = '{$row['it_id']}'
                          and od_id = '$s_cart_id' ";
            $sum = sql_fetch($sql);

 

위의 노란부분의 합계(price)가 item_option type=1인 경우에 

 (io_price * ct_qty) + ((ct_price + io_price) * ct_qty)))  인가요?

 아니면

 ((ct_price + io_price) * ct_qty))) 인가요?

이 질문에 댓글 쓰기 :

답변 2

mysql 의 if문은

 

다른 dbms의 decode와 동일하다고 보시면 됩니다.

 

if (조건, 참, 거짓)

 

그러면 위의 문장에서 수행될 내용은


SUM (
      IF(  io_type = 1
          , (io_price * ct_qty)
          , ((ct_price + io_price) * ct_qty)
       )
   ) as price,

 

이니

sum을 할때 레코드마다

 

io_type = 1 이면

   (io_price * ct_qty)

아니면

   ((ct_price + io_price) * ct_qty)

를 합산합니다.

 

 

 

답변을 작성하시기 전에 로그인 해주세요.
전체 123,532 | RSS
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT