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

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

QA

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

답변 2

본문

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)

를 합산합니다.

 

 

 

답변을 작성하시기 전에 로그인 해주세요.
QA 내용 검색
질문등록
전체 1,271
© SIRSOFT
현재 페이지 제일 처음으로