| 제목 | 엑티브 레코드 질문 드립니다. | ||
|---|---|---|---|
| 글쓴이 | 책상다리 | 작성시각 | 2015/12/14 18:42:05 | 
|  | |||
| 우선 메뉴얼에는 
 $this->db->set('field', 'field+1', FALSE);$this->db->insert('mytable'); // gives INSERT INTO mytable (field) VALUES (field+1)$this->db->set('field', 'field+1');$this->db->insert('mytable'); // gives INSERT INTO mytable (field) VALUES ('field+1') 
 이렇게 되었는데요. 
 제가 적용시킬 코드는 $price = 랜덤한 숫자 $this->db->set('nTotalChargePrice','nTotalChargePrice'+$price); $this->db->where('id',$id); $this->db->update('MainPrice'); 입니다. 
 위 쿼리문을 적용시키려고 하는데 echo $this->db->last_query(); 이걸로 찍어봤습니다만, $this->db->set('nTotalChargePrice','nTotalChargePrice'+$price); 요부분이 좀 말썽입니다. nTotalChargePrice에 10000이라는 값이 들어가있고, $price가 20000일때 원하는 값은 30000인데 20000이라는 값이 들어갑니다.;; 기존의 nTotalChargePrice 값이 더해지지 않는거죠... 
 올바른 액티브 쿼리를 알려주시면 감사하겠습니다 ㅠㅠ | |||
| 다음글 | 세션 재 질문 (1) | ||
| 이전글 | 컨트롤 관련 질문드립니다. (2) | ||
| 
                                taegon
                                /
                                2015/12/14 19:09:15 /
                                추천
                                0
                             | 
| 
                                책상다리
                                /
                                2015/12/15 10:27:07 /
                                추천
                                0
                             taegon님// 감사합니다! | 
$this->db->set('nTotalChargePrice','nTotalChargePrice'+$price);
이 부분이 잘못된것 같습니다. 원하시는대로 SET nTotalChargePrice = nTotalChargePrice + {$price}가 되시려면
$this->db->set('nTotalChargePrice','nTotalChargePrice + ' . $price, FALSE);
이렇게 변경하셔야 합니다.
---------------------------------------------------------------------------------------------------------
set 구문에 FALSE가 빠져 추가합니다.